LCDproc development and user support list

Text archives Help


[Lcdproc] g15 updates


Chronological Thread 
  • From: mirabeaj AT gmail.com (Anthony J. Mirabella)
  • Subject: [Lcdproc] g15 updates
  • Date: Sun Nov 12 01:36:01 2006

Here's a patch that deals with a change in behavior in the upcoming
g15daemon release. The old behavior is handled via a version check so
it works regardless which version of g15daemon is used. The first part
of the patch, removing a couple of free() calls, fixes a double free
error that I've seen when exiting LCDd.
Index: g15.c
===================================================================
RCS file: /cvsroot/lcdproc/lcdproc/server/drivers/g15.c,v
retrieving revision 1.1
diff -a -u -r1.1 g15.c
--- g15.c	13 Aug 2006 15:55:47 -0000	1.1
+++ g15.c	12 Nov 2006 01:25:53 -0000
@@ -30,6 +30,7 @@
 #include <errno.h>
 #include <syslog.h>
 #include <sys/socket.h>
+#include <sys/types.h>
 #include <libg15.h>
 #include <g15daemon_client.h>
 #include <libg15render.h>
@@ -109,15 +110,8 @@
 	
 	g15_close_screen(p->g15screen_fd);
 	
-	if (p != NULL) {
-		if (p->canvas)
-			free(p->canvas);
-		
-		if (p->backingstore)
-			free(p->backingstore);
-
-		free(p);
-	}
+	if (p != NULL)
+	  free(p);
 	drvthis->store_private_ptr(drvthis, NULL);
 }
 
@@ -372,14 +366,36 @@
 MODULE_EXPORT const char * g15_get_key (Driver *drvthis)
 {
 	PrivateData *p = drvthis->private_data;
-	
+	const char *g15d_ver = g15daemon_version();
+	int toread = 0;
 	unsigned int key_state = 0;
-	
-	if(send(p->g15screen_fd, "k", 1, MSG_OOB)<1) /* request key status */
-        report(RPT_INFO, "%s: Error in send to g15daemon", drvthis->name);    
 
-    	recv(p->g15screen_fd, &key_state , sizeof(key_state),0);
+	if ((strncmp("1.2", g15d_ver, 3)))
+	  {	/* other than g15daemon-1.2 (should be >=1.9) */
+		fd_set fds;
+		struct timeval tv;
+		memset (&tv, 0, sizeof(struct timeval));
+
+		FD_ZERO(&fds);
+		FD_SET(p->g15screen_fd, &fds);
+	
+		toread = select(FD_SETSIZE, &fds, NULL, NULL, &tv);
+	  }
+	else
+	  {	/* g15daemon-1.2 */
+		if(send(p->g15screen_fd, "k", 1, MSG_OOB)<1) /* request key status */
+		  {
+	 	  	report(RPT_INFO, "%s: Error in send to g15daemon", drvthis->name);
+			return NULL;
+		  }
+		toread = 1;
+	  }
 	
+	if (toread >= 1)
+	  read(p->g15screen_fd, &key_state, sizeof(key_state));
+	else
+	  return NULL;
+
 	if (key_state & G15_KEY_G1)
 		return "Escape";
 	else if (key_state & G15_KEY_L1)

Attachment: signature.asc
Description: OpenPGP digital signature



  • [Lcdproc] g15 updates, Anthony J. Mirabella, 11/12/2006

Archive powered by MHonArc 2.6.18.

Top of page