print everything to stderr, and fflush on PDEBUG

This commit is contained in:
rofl0r 2012-07-08 04:12:17 +02:00
parent 1fc7e38ee0
commit 364c785970
2 changed files with 9 additions and 16 deletions

View File

@ -230,26 +230,15 @@ static int timed_connect(int sock, const struct sockaddr *addr, socklen_t len) {
pfd[0].events = POLLOUT;
fcntl(sock, F_SETFL, O_NONBLOCK);
ret = true_connect(sock, addr, len);
#ifdef DEBUG
if(ret == -1)
perror("true_connect");
printf("\nconnect ret=%d\n", ret);
fflush(stdout);
#endif
PDEBUG("\nconnect ret=%d\n", ret);
if(ret == -1 && errno == EINPROGRESS) {
ret = poll_retry(pfd, 1, tcp_connect_time_out);
#ifdef DEBUG
printf("\npoll ret=%d\n", ret);
fflush(stdout);
#endif
PDEBUG("\npoll ret=%d\n", ret);
if(ret == 1) {
value_len = sizeof(socklen_t);
getsockopt(sock, SOL_SOCKET, SO_ERROR, &value, &value_len);
#ifdef DEBUG
printf("\nvalue=%d\n", value);
fflush(stdout);
#endif
PDEBUG("\nvalue=%d\n", value);
if(!value)
ret = 0;
else
@ -258,6 +247,10 @@ static int timed_connect(int sock, const struct sockaddr *addr, socklen_t len) {
ret = -1;
}
} else {
#ifdef DEBUG
if(ret == -1)
perror("true_connect");
#endif
if(ret != 0)
ret = -1;
}

View File

@ -132,7 +132,7 @@ int proxy_getaddrinfo(const char *node, const char *service,
void pc_stringfromipv4(unsigned char *ip_buf_4_bytes, char *outbuf_16_bytes);
#ifdef DEBUG
# define PDEBUG(fmt, args...) fprintf(stderr,"DEBUG:"fmt, ## args)
# define PDEBUG(fmt, args...) do { fprintf(stderr,"DEBUG:"fmt, ## args); fflush(stderr); } while(0)
#else
# define PDEBUG(fmt, args...) do {} while (0)
#endif