Bug 184015

Summary: [patch] sysutils/synergy: hang on reading config
Product: Ports & Packages Reporter: Henry Hu <henry.hu.sh>
Component: Individual Port(s)Assignee: Kevin Lo <kevlo>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Latest   
Hardware: Any   
OS: Any   
Attachments:
Description Flags
file.diff none

Description Henry Hu 2013-11-16 04:40:01 UTC
Currently, with sysutils/synergy 1.3.8, if you
1. create a config file ~/.synergy.conf
2. run synergys -f
You can see that synergys hangs on reading the config file, and its CPU usage is 100%.

The reason is that, in the freebsd patch to CConfig.cpp, it writes

--- src/lib/server/CConfig.cpp.orig	2011-01-21 11:51:35.000000000 +0800
+++ src/lib/server/CConfig.cpp	2013-09-12 17:23:04.000000000 +0800
@@ -1908,9 +1908,9 @@
 	return m_line;
 }
 
-CConfigReadContext::operator void*() const
+CConfigReadContext::operator bool() const
 {
-	return m_stream;
+	return !m_stream.bad();
 }
 
However, when m_stream hit eof, its eof() is true, but its bad() is false. So although the stream has reached its end, the program still tries to read from it.

The correct way to check this is by checking the good() flag.

After changing that line to
    return m_stream.good();
synergys works correctly.

Fix: Patch attached with submission follows:
How-To-Repeat: 1. install sysutils/synergy
2. create a config file ~/.synergy.conf
3. run synergys -f

It hangs.
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-11-16 04:40:10 UTC
Responsible Changed
From-To: freebsd-ports-bugs->kevlo

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 dfilter service freebsd_committer freebsd_triage 2013-11-26 02:17:02 UTC
Author: kevlo
Date: Tue Nov 26 02:16:54 2013
New Revision: 334913
URL: http://svnweb.freebsd.org/changeset/ports/334913

Log:
  - Fix hang on reading config [1]
  - support STAGE
  
  PR:	ports/184015 [1]
  Submitted by:	Henry Hu <henry.hu.sh at gmail dot com>

Modified:
  head/sysutils/synergy/Makefile
  head/sysutils/synergy/files/patch-CConfig.cpp

Modified: head/sysutils/synergy/Makefile
==============================================================================
--- head/sysutils/synergy/Makefile	Tue Nov 26 01:46:40 2013	(r334912)
+++ head/sysutils/synergy/Makefile	Tue Nov 26 02:16:54 2013	(r334913)
@@ -2,6 +2,7 @@
 
 PORTNAME=	synergy
 PORTVERSION=	1.3.8
+PORTREVISION=	1
 DISTVERSIONSUFFIX=	-Source
 CATEGORIES=	sysutils
 MASTER_SITES=	GOOGLE_CODE
@@ -23,15 +24,14 @@ PLIST_FILES=	bin/synergys bin/synergyc
 PORTEXAMPLES=	synergy.conf.example synergy.conf.example-basic \
 		synergy.conf.example-advanced
 
-NO_STAGE=	yes
 do-install:
 .for f in synergys synergyc
-	${INSTALL_PROGRAM} ${WRKSRC}/bin/${f} ${PREFIX}/bin
+	${INSTALL_PROGRAM} ${WRKSRC}/bin/${f} ${STAGEDIR}${PREFIX}/bin
 .endfor
 .if !defined(NOPORTEXAMPLES)
-	${MKDIR} ${EXAMPLESDIR}
+	${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
 .for f in ${PORTEXAMPLES}
-	${INSTALL_DATA} ${WRKSRC}/doc/${f} ${EXAMPLESDIR}
+	${INSTALL_DATA} ${WRKSRC}/doc/${f} ${STAGEDIR}${EXAMPLESDIR}
 .endfor
 .endif
 

Modified: head/sysutils/synergy/files/patch-CConfig.cpp
==============================================================================
--- head/sysutils/synergy/files/patch-CConfig.cpp	Tue Nov 26 01:46:40 2013	(r334912)
+++ head/sysutils/synergy/files/patch-CConfig.cpp	Tue Nov 26 02:16:54 2013	(r334913)
@@ -1,5 +1,5 @@
 --- src/lib/server/CConfig.cpp.orig	2011-01-21 11:51:35.000000000 +0800
-+++ src/lib/server/CConfig.cpp	2013-09-12 17:23:04.000000000 +0800
++++ src/lib/server/CConfig.cpp	2013-11-26 10:00:44.000000000 +0800
 @@ -1908,9 +1908,9 @@
  	return m_line;
  }
@@ -8,7 +8,7 @@
 +CConfigReadContext::operator bool() const
  {
 -	return m_stream;
-+	return !m_stream.bad();
++	return m_stream.good();
  }
  
  bool
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 3 Kevin Lo freebsd_committer freebsd_triage 2013-11-26 02:17:14 UTC
State Changed
From-To: open->closed

Committed, thanks.