>>>>> On Wed, 1 Sep 2010 21:01:02 +0200, Bart Van Assche <[email protected]>
>>>>> said:
BVA> The above patch only addresses one of the two fopen() calls in the
BVA> loop. What about the second fopen() call ? Why not to check its
BVA> return value too ?
Well, you're right I didn't check the second one.
BVA> And, more importantly, if fopen() fails, shouldn't the just created entry
be
BVA> removed again from the container ?
If you saw my other response, I actually moved the container insertion
to below the fopen.
IE, this one:
diff --git a/net-snmp/agent/mibgroup/host/data_access/swrun_procfs_status.c
b/net-snmp/agent/mibgroup/host/data_access/swrun_procfs_status.c
index 0c562f6..77d4394 100644
--- a/net-snmp/agent/mibgroup/host/data_access/swrun_procfs_status.c
+++ b/net-snmp/agent/mibgroup/host/data_access/swrun_procfs_status.c
@@ -71,7 +71,6 @@ netsnmp_arch_swrun_container_load( netsnmp_container
*container, u_int flags)
entry = netsnmp_swrun_entry_create(pid);
if (NULL == entry)
continue; /* error already logged by function */
- rc = CONTAINER_INSERT(container, entry);
/*
* Now extract the interesting information
@@ -83,10 +82,14 @@ netsnmp_arch_swrun_container_load( netsnmp_container
*container, u_int flags)
*/
snprintf( buf2, BUFSIZ, "/proc/%d/status", pid );
fp = fopen( buf2, "r" );
+ if (!fp)
+ continue; /* file (process) probably went away */
memset(buf, 0, sizeof(buf));
fgets( buf, BUFSIZ-1, fp );
fclose(fp);
+ rc = CONTAINER_INSERT(container, entry);
+
for ( cp = buf; *cp != ':'; cp++ )
;
while (isspace(*(++cp))) /* Skip ':' and following spaces */
--
Wes Hardaker
Please mail all replies to [email protected]
------------------------------------------------------------------------------
This SF.net Dev2Dev email is sponsored by:
Show off your parallel programming skills.
Enter the Intel(R) Threading Challenge 2010.
http://p.sf.net/sfu/intel-thread-sfd
_______________________________________________
Net-snmp-coders mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders