[or-cvs] Use socketclose on windows as appropriate; end pid files wi...

Nick Mathewson nickm at seul.org
Wed Apr 28 21:14:58 UTC 2004


Update of /home/or/cvsroot/src/common
In directory moria.mit.edu:/tmp/cvs-serv20395/src/common

Modified Files:
	util.c util.h 
Log Message:
Use socketclose on windows as appropriate; end pid files with newline

Index: util.c
===================================================================
RCS file: /home/or/cvsroot/src/common/util.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -u -d -r1.91 -r1.92
--- util.c	28 Apr 2004 20:13:21 -0000	1.91
+++ util.c	28 Apr 2004 21:14:56 -0000	1.92
@@ -930,7 +930,7 @@
         goto tidy_up_and_fail;
     if (size != sizeof(listen_addr))
         goto abort_tidy_up_and_fail;
-    close(listener);
+    tor_close_socket(listener);
     /* Now check we are talking to ourself by matching port and host on the
        two sockets.  */
     if (getsockname(connector, (struct sockaddr *) &connect_addr, &size) == -1)
@@ -955,11 +955,11 @@
     {
         int save_errno = errno;
         if (listener != -1)
-            close(listener);
+            tor_close_socket(listener);
         if (connector != -1)
-            close(connector);
+            tor_close_socket(connector);
         if (acceptor != -1)
-            close(acceptor);
+            tor_close_socket(acceptor);
         errno = save_errno;
         return -1;
     }
@@ -1319,7 +1319,7 @@
     log_fn(LOG_WARN, "unable to open %s for writing: %s", filename,
            strerror(errno));
   } else {
-    fprintf(pidfile, "%d", (int)getpid());
+    fprintf(pidfile, "%d\n", (int)getpid());
     fclose(pidfile);
   }
 #endif

Index: util.h
===================================================================
RCS file: /home/or/cvsroot/src/common/util.h,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- util.h	28 Apr 2004 20:31:32 -0000	1.60
+++ util.h	28 Apr 2004 21:14:56 -0000	1.61
@@ -56,6 +56,12 @@
  } } while (0)
 #endif
 
+#ifdef MS_WINDOWS
+#define tor_close_socket(s) socketclose(s)
+#else
+#define tor_close_socket(s) close(s)
+#endif
+
 /* legal characters in a filename */
 #define CONFIG_LEGAL_FILENAME_CHARACTERS "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789.-_/"
 



More information about the tor-commits mailing list