[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[or-cvs] remember; tor_socket_errno has side effects!
Update of /home/or/cvsroot/tor/src/or
In directory moria.mit.edu:/tmp/cvs-serv23637/src/or
Modified Files:
buffers.c connection.c main.c
Log Message:
remember; tor_socket_errno has side effects!
Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/buffers.c,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- buffers.c 26 Nov 2004 04:00:52 -0000 1.116
+++ buffers.c 28 Nov 2004 05:48:02 -0000 1.117
@@ -184,7 +184,8 @@
// log_fn(LOG_DEBUG,"reading at most %d bytes.",at_most);
read_result = recv(s, buf->mem+buf->datalen, at_most, 0);
if (read_result < 0) {
- if(!ERRNO_IS_EAGAIN(tor_socket_errno(s))) { /* it's a real error */
+ int e = tor_socket_errno(s);
+ if(!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
return -1;
}
return 0; /* would block. */
@@ -254,7 +255,8 @@
write_result = send(s, buf->mem, *buf_flushlen, 0);
if (write_result < 0) {
- if(!ERRNO_IS_EAGAIN(tor_socket_errno(s))) { /* it's a real error */
+ int e = tor_socket_errno(s);
+ if(!ERRNO_IS_EAGAIN(e)) { /* it's a real error */
return -1;
}
log_fn(LOG_DEBUG,"write() would block, returning.");
Index: connection.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/connection.c,v
retrieving revision 1.299
retrieving revision 1.300
diff -u -d -r1.299 -r1.300
--- connection.c 26 Nov 2004 04:00:52 -0000 1.299
+++ connection.c 28 Nov 2004 05:48:02 -0000 1.300
@@ -538,10 +538,11 @@
log_fn(LOG_DEBUG,"Connecting to %s:%u.",address,port);
if(connect(s,(struct sockaddr *)&dest_addr,sizeof(dest_addr)) < 0) {
- if(!ERRNO_IS_CONN_EINPROGRESS(tor_socket_errno(s))) {
+ int e = tor_socket_errno(s);
+ if(!ERRNO_IS_CONN_EINPROGRESS(e)) {
/* yuck. kill it. */
log_fn(LOG_INFO,"Connect() to %s:%u failed: %s",address,port,
- tor_socket_strerror(tor_socket_errno(s)));
+ tor_socket_strerror(e));
tor_close_socket(s);
return -1;
} else {
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/tor/src/or/main.c,v
retrieving revision 1.393
retrieving revision 1.394
diff -u -d -r1.393 -r1.394
--- main.c 26 Nov 2004 04:19:03 -0000 1.393
+++ main.c 28 Nov 2004 05:48:02 -0000 1.394
@@ -869,11 +869,11 @@
/* let catch() handle things like ^c, and otherwise don't worry about it */
if (poll_result < 0) {
+ int e = tor_socket_errno(-1);
/* let the program survive things like ^z */
- if(tor_socket_errno(-1) != EINTR) {
+ if(e != EINTR) {
log_fn(LOG_ERR,"poll failed: %s [%d]",
- tor_socket_strerror(tor_socket_errno(-1)),
- tor_socket_errno(-1));
+ tor_socket_strerror(e), e);
return -1;
} else {
log_fn(LOG_DEBUG,"poll interrupted.");