[Initng-svn] r3199 - initng/trunk/src
svn at initng.thinktux.net
svn at initng.thinktux.net
Sun Mar 5 01:33:21 CET 2006
Author: makomk
Date: Sun Mar 5 01:33:21 2006
New Revision: 3199
Modified:
initng/trunk/src/initng_fd.c
Log:
Fix 100% CPU usage
Modified: initng/trunk/src/initng_fd.c
==============================================================================
--- initng/trunk/src/initng_fd.c (original)
+++ initng/trunk/src/initng_fd.c Sun Mar 5 01:33:21 2006
@@ -98,12 +98,13 @@
int chars_read=0;
int old_content_offset = 0;
int read_ret = 0;
+ int is_eof = FALSE;
D_("\ninitng_fd_process_read_input(%s, %s, %i);\n", service->name, p->pt->name);
if(p->out_pipe[0]<=0)
{
- F_("FIFO, can be read! NOT OPEN!\n");
+ F_("FIFO, can't be read! NOT OPEN!\n");
return;
}
@@ -161,6 +162,11 @@
/* make sure read does not return -1 */
if (read_ret < 0)
break;
+
+ if(read_ret == 0)
+ {
+ is_eof = TRUE; break;
+ }
/* make sure its nulled at end */
read_pos[read_ret]='\0';
@@ -177,6 +183,21 @@
/* let all plugin take part of data */
initng_fd_plugin_readpipe(service, p, p->buffer + old_content_offset);
}
+
+ if (is_eof)
+ {
+ D_("Freeing buffer for %s\n", service->name);
+ if (p->out_pipe[0] > 0)
+ close(p->out_pipe[0]);
+ if (p->out_pipe[1] > 0)
+ close(p->out_pipe[1]);
+ if (p->buffer)
+ free(p->buffer);
+ p->out_pipe[0] = -1;
+ p->out_pipe[1] = -1;
+ p->buffer = NULL;
+ return;
+ }
/* if buffer reached 10000 chars */
if(old_content_offset + chars_read > 10000)
@@ -317,6 +338,7 @@
qC = NULL;
while_list_safe(currentC, &g.FDWATCHERS, qC)
{
+ int fd = currentC->c.fdh->fds;
if (currentC->c.fdh->fds <= 2)
continue;
if (!currentC->c.fdh->call_module)
@@ -326,7 +348,7 @@
D_("Calling plugin handler for fd #%i\n", currentC->c.fdh->fds);
(*currentC->c.fdh->call_module) (currentC->c.fdh);
- D_("plugin handler for fd #%i returned!\n", currentC->c.fdh->fds);
+ D_("plugin handler for fd #%i returned!\n", fd);
/* Found match, that means we need to look for one less, if we've found all we should then return */
retval--;
More information about the Initng-svn
mailing list