Use socketclose on windows as appropriate; end pid files with newline

svn:r1745
This commit is contained in:
Nick Mathewson
2004-04-28 21:14:56 +00:00
parent 4049ee558d
commit b7fa6385a4
6 changed files with 20 additions and 14 deletions
+5 -5
View File
@@ -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
+6
View File
@@ -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.-_/"