| diff -Naur netperf-2.4.4.orig/src/netlib.c netperf-2.4.4.patched/src/netlib.c |
| --- netperf-2.4.4.orig/src/netlib.c 2007-10-18 01:16:02.000000000 +0400 |
| +++ netperf-2.4.4.patched/src/netlib.c 2008-01-30 22:03:01.000000000 +0300 |
| @@ -244,6 +244,7 @@ |
| union netperf_response_struct netperf_response; |
| |
| FILE *where; |
| +int fd = -1; |
| |
| char libfmt = '?'; |
| |
| diff -Naur netperf-2.4.4.orig/src/netlib.h netperf-2.4.4.patched/src/netlib.h |
| --- netperf-2.4.4.orig/src/netlib.h 2007-10-18 01:17:37.000000000 +0400 |
| +++ netperf-2.4.4.patched/src/netlib.h 2008-01-30 21:46:34.000000000 +0300 |
| @@ -445,6 +445,7 @@ |
| extern SOCKET server_sock; |
| extern int times_up; |
| extern FILE *where; |
| +extern int fd; |
| extern int loops_per_msec; |
| extern float lib_local_per_cpu_util[]; |
| |
| diff -Naur netperf-2.4.4.orig/src/netserver.c netperf-2.4.4.patched/src/netserver.c |
| --- netperf-2.4.4.orig/src/netserver.c 2007-10-18 01:09:12.000000000 +0400 |
| +++ netperf-2.4.4.patched/src/netserver.c 2008-01-30 21:57:56.000000000 +0300 |
| @@ -153,6 +153,9 @@ |
| char listen_port[10]; |
| extern char *optarg; |
| extern int optind, opterr; |
| +#if !defined(WIN_32) |
| +char debuglog[] = "/tmp/netperf.debugXXXXXX"; |
| +#endif |
| |
| #ifndef WIN32 |
| #define SERVER_ARGS "dL:n:p:v:V46" |
| @@ -225,6 +228,10 @@ |
| if (!debug) |
| { |
| fclose(where); |
| +#if !defined(WIN32) |
| + unlink(debuglog); |
| + close(fd); |
| +#endif |
| #if !defined(WIN32) && !defined(MPE) && !defined(__VMS) |
| /* For Unix: reopen the debug write file descriptor to "/dev/null" */ |
| /* and redirect stdout to it. */ |
| @@ -918,8 +925,11 @@ |
| strcpy(FileName, DEBUG_LOG_FILE); |
| |
| #ifndef WIN32 |
| - snprintf(&FileName[strlen(FileName)], sizeof(FileName) - strlen(FileName), "_%d", getpid()); |
| - if ((where = fopen(FileName, "w")) == NULL) { |
| + if((fd = mkstemp(debuglog)) == -1 || (where = fdopen(fd, "w+")) == NULL){ |
| + if(fd != -1){ |
| + unlink(debuglog); |
| + close(fd); |
| + } |
| perror("netserver: debug file"); |
| exit(1); |
| } |
| @@ -947,10 +957,6 @@ |
| } |
| } |
| #endif |
| - |
| -#ifndef WIN32 |
| - chmod(DEBUG_LOG_FILE,0644); |
| -#endif |
| |
| #if WIN32 |
| if (child) { |