diff options
author | Nick Mathewson <nickm@torproject.org> | 2004-04-28 21:14:56 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2004-04-28 21:14:56 +0000 |
commit | 9322641710fec0f90cc47b64748a9795ce7cba9b (patch) | |
tree | 98388c1bae7eb6a4162985f3f01e6d0c3e9bf115 /src/common | |
parent | dd335d9bb25b1e772f0d42aa35d25895d8031c36 (diff) | |
download | tor-9322641710fec0f90cc47b64748a9795ce7cba9b.tar tor-9322641710fec0f90cc47b64748a9795ce7cba9b.tar.gz |
Use socketclose on windows as appropriate; end pid files with newline
svn:r1745
Diffstat (limited to 'src/common')
-rw-r--r-- | src/common/util.c | 10 | ||||
-rw-r--r-- | src/common/util.h | 6 |
2 files changed, 11 insertions, 5 deletions
diff --git a/src/common/util.c b/src/common/util.c index 9c834db58..a7c1adecb 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -930,7 +930,7 @@ tor_socketpair(int family, int type, int protocol, int fd[2]) 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 @@ tor_socketpair(int family, int type, int protocol, int fd[2]) { 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 @@ void write_pidfile(char *filename) { 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 diff --git a/src/common/util.h b/src/common/util.h index aedc9ae60..555aa6b05 100644 --- a/src/common/util.h +++ b/src/common/util.h @@ -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.-_/" |