mirror of
https://github.com/Llewellynvdm/conky.git
synced 2024-11-18 02:55:12 +00:00
infopipe work in progress
git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky@464 7f574dfc-610e-0410-a909-a81674777703
This commit is contained in:
parent
09a10701df
commit
3e3c686c7b
@ -90,28 +90,28 @@ void *infopipe_service(void *pvoid)
|
||||
FD_ZERO(&readset);
|
||||
FD_SET(fd,&readset);
|
||||
|
||||
/* This select() can block for a brief while (tm time value) and is
|
||||
ideally suited for a worker thread such as this. We don't want to
|
||||
slow down ui updates in the main thread as there is already excess
|
||||
latency there. */
|
||||
if (select(fd+1,&readset,NULL,NULL,&tm) != 1) /* nothing to read yet */
|
||||
break;
|
||||
/* The select() below can block for a brief time (tm value) and is
|
||||
ideally suited for a worker thread such as this. We don't want
|
||||
to slow down ui updates in the main thread as there is already
|
||||
excess latency there. */
|
||||
if (select(fd+1,&readset,NULL,NULL,&tm) == 1) { /* something to read */
|
||||
|
||||
if (read(fd,buf,sizeof(buf))>0) {
|
||||
if (read(fd,buf,sizeof(buf)) > 0) { /* buf has data */
|
||||
|
||||
pbuf=buf;
|
||||
pthread_mutex_lock(&info.infopipe.item_mutex);
|
||||
for (i=0;i<14;i++) {
|
||||
sscanf(pbuf,"%*[^:]: %[^\n]",g_item[i]);
|
||||
while(*pbuf++ != '\n');
|
||||
}
|
||||
pthread_mutex_unlock(&info.infopipe.item_mutex);
|
||||
|
||||
/* -- debug to console --
|
||||
for(i=0;i<14;i++)
|
||||
printf("%s\n",g_item[i]);
|
||||
*/
|
||||
pbuf=buf;
|
||||
pthread_mutex_lock(&info.infopipe.item_mutex);
|
||||
for (i=0;i<14;i++) {
|
||||
/* 14 lines of key: value pairs presented in a known order */
|
||||
sscanf(pbuf,"%*[^:]: %[^\n]",g_item[i]);
|
||||
while(*pbuf++ != '\n');
|
||||
}
|
||||
pthread_mutex_unlock(&info.infopipe.item_mutex);
|
||||
|
||||
/* -- debug to console --
|
||||
for(i=0;i<14;i++)
|
||||
printf("%s\n",g_item[i]);
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
if (close(fd)<0)
|
||||
|
Loading…
Reference in New Issue
Block a user