1
0
mirror of https://github.com/moparisthebest/curl synced 2025-03-01 01:41:50 -05:00

add debug messages for initialization failures

This commit is contained in:
Yang Tse 2007-02-19 02:03:58 +00:00
parent cbf58d88d0
commit 31e598d2f3
8 changed files with 66 additions and 11 deletions

View File

@ -224,6 +224,7 @@ static int file_lookup(union ares_addr *addr, int family, struct hostent **host)
switch(error) switch(error)
{ {
case ENOENT: case ENOENT:
case ESRCH:
return ARES_ENOTFOUND; return ARES_ENOTFOUND;
default: default:
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",

View File

@ -248,6 +248,7 @@ static int file_lookup(const char *name, int family, struct hostent **host)
FILE *fp; FILE *fp;
char **alias; char **alias;
int status; int status;
int error;
#ifdef WIN32 #ifdef WIN32
char PATH_HOSTS[MAX_PATH]; char PATH_HOSTS[MAX_PATH];
@ -280,8 +281,22 @@ static int file_lookup(const char *name, int family, struct hostent **host)
fp = fopen(PATH_HOSTS, "r"); fp = fopen(PATH_HOSTS, "r");
if (!fp) if (!fp)
return ARES_ENOTFOUND; {
error = ERRNO;
switch(error)
{
case ENOENT:
case ESRCH:
return ARES_ENOTFOUND;
default:
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
error, strerror(error)));
DEBUGF(fprintf(stderr, "Error opening file: %s\n",
PATH_HOSTS));
*host = NULL;
return ARES_EFILE;
}
}
while ((status = ares__get_hostent(fp, family, host)) == ARES_SUCCESS) while ((status = ares__get_hostent(fp, family, host)) == ARES_SUCCESS)
{ {
if (strcasecmp((*host)->h_name, name) == 0) if (strcasecmp((*host)->h_name, name) == 0)

View File

@ -639,6 +639,7 @@ DhcpNameServer
error = ERRNO; error = ERRNO;
switch(error) { switch(error) {
case ENOENT: case ENOENT:
case ESRCH:
status = ARES_EOF; status = ARES_EOF;
break; break;
default: default:
@ -664,6 +665,7 @@ DhcpNameServer
error = ERRNO; error = ERRNO;
switch(error) { switch(error) {
case ENOENT: case ENOENT:
case ESRCH:
status = ARES_EOF; status = ARES_EOF;
break; break;
default: default:
@ -690,6 +692,7 @@ DhcpNameServer
error = ERRNO; error = ERRNO;
switch(error) { switch(error) {
case ENOENT: case ENOENT:
case ESRCH:
status = ARES_EOF; status = ARES_EOF;
break; break;
default: default:
@ -716,6 +719,7 @@ DhcpNameServer
error = ERRNO; error = ERRNO;
switch(error) { switch(error) {
case ENOENT: case ENOENT:
case ESRCH:
status = ARES_EOF; status = ARES_EOF;
break; break;
default: default:

View File

@ -273,6 +273,7 @@ static int single_domain(ares_channel channel, const char *name, char **s)
switch(error) switch(error)
{ {
case ENOENT: case ENOENT:
case ESRCH:
break; break;
default: default:
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n", DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",

View File

@ -353,7 +353,7 @@ static int juggle(curl_socket_t *sockfdp,
client connecting. */ client connecting. */
sockfd = accept(sockfd, NULL, NULL); sockfd = accept(sockfd, NULL, NULL);
if(CURL_SOCKET_BAD == sockfd) if(CURL_SOCKET_BAD == sockfd)
logmsg("accept() failed\n"); logmsg("accept() failed");
else { else {
logmsg("====> Client connect"); logmsg("====> Client connect");
write(fileno(stdout), "CNCT\n", 5); write(fileno(stdout), "CNCT\n", 5);
@ -438,7 +438,7 @@ static curl_socket_t sockdaemon(curl_socket_t sock,
if(getsockname(sock, (struct sockaddr *) &add, if(getsockname(sock, (struct sockaddr *) &add,
&socksize)<0) { &socksize)<0) {
fprintf(stderr, "getsockname() failed"); logmsg("getsockname() failed with error: %d", SOCKERRNO);
return CURL_SOCKET_BAD; return CURL_SOCKET_BAD;
} }
*port = ntohs(add.sin_port); *port = ntohs(add.sin_port);
@ -489,6 +489,7 @@ int main(int argc, char *argv[])
FILE *pidfile; FILE *pidfile;
char *pidname= (char *)".sockfilt.pid"; char *pidname= (char *)".sockfilt.pid";
int rc; int rc;
int error;
int arg=1; int arg=1;
enum sockmode mode = PASSIVE_LISTEN; /* default */ enum sockmode mode = PASSIVE_LISTEN; /* default */
@ -631,7 +632,10 @@ int main(int argc, char *argv[])
logmsg("Wrote pid %d to %s", pid, pidname); logmsg("Wrote pid %d to %s", pid, pidname);
} }
else { else {
fprintf(stderr, "Couldn't write pid file\n"); error = ERRNO;
logmsg("fopen() failed with error: %d %s\n", error, strerror(error));
logmsg("Error opening file: %s\n", pidname);
logmsg("Couldn't write pid file\n");
sclose(sock); sclose(sock);
return 1; return 1;
} }

View File

@ -197,6 +197,7 @@ int ProcessRequest(struct httprequest *req)
char logbuf[256]; char logbuf[256];
int prot_major, prot_minor; int prot_major, prot_minor;
char *end; char *end;
int error;
end = strstr(line, END_OF_HEADERS); end = strstr(line, END_OF_HEADERS);
logmsg("ProcessRequest() called"); logmsg("ProcessRequest() called");
@ -263,6 +264,9 @@ int ProcessRequest(struct httprequest *req)
stream=fopen(filename, "rb"); stream=fopen(filename, "rb");
if(!stream) { if(!stream) {
error = ERRNO;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file %d", req->testno); logmsg("Couldn't open test file %d", req->testno);
req->open = FALSE; /* closes connection */ req->open = FALSE; /* closes connection */
return 1; /* done */ return 1; /* done */
@ -569,6 +573,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
FILE *dump; FILE *dump;
int persistant = TRUE; int persistant = TRUE;
size_t responsesize; size_t responsesize;
int error;
static char weare[256]; static char weare[256];
@ -646,6 +651,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
stream=fopen(filename, "rb"); stream=fopen(filename, "rb");
if(!stream) { if(!stream) {
error = ERRNO;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file"); logmsg("Couldn't open test file");
return 0; return 0;
} }
@ -658,6 +666,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
/* re-open the same file again */ /* re-open the same file again */
stream=fopen(filename, "rb"); stream=fopen(filename, "rb");
if(!stream) { if(!stream) {
error = ERRNO;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", filename);
logmsg("Couldn't open test file"); logmsg("Couldn't open test file");
return 0; return 0;
} }
@ -670,6 +681,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
dump = fopen(RESPONSE_DUMP, "ab"); /* b is for windows-preparing */ dump = fopen(RESPONSE_DUMP, "ab"); /* b is for windows-preparing */
if(!dump) { if(!dump) {
error = ERRNO;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", RESPONSE_DUMP);
logmsg("couldn't create logfile: " RESPONSE_DUMP); logmsg("couldn't create logfile: " RESPONSE_DUMP);
return -1; return -1;
} }
@ -872,7 +886,10 @@ int main(int argc, char *argv[])
fclose(pidfile); fclose(pidfile);
} }
else { else {
fprintf(stderr, "Couldn't write pid file\n"); error = ERRNO;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", pidname);
logmsg("Couldn't write pid file");
sclose(sock); sclose(sock);
return 1; return 1;
} }

View File

@ -424,6 +424,7 @@ int main(int argc, char **argv)
curl_socket_t sock; curl_socket_t sock;
int flag; int flag;
int rc; int rc;
int error;
struct testcase test; struct testcase test;
while(argc>arg) { while(argc>arg) {
@ -513,8 +514,12 @@ int main(int argc, char **argv)
fprintf(pidfile, "%d\n", (int)getpid()); fprintf(pidfile, "%d\n", (int)getpid());
fclose(pidfile); fclose(pidfile);
} }
else else {
fprintf(stderr, "Couldn't write pid file\n"); error = ERRNO;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", pidname);
logmsg("Couldn't write pid file");
}
logmsg("Running IPv%d version on port UDP/%d", logmsg("Running IPv%d version on port UDP/%d",
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
@ -554,8 +559,12 @@ int main(int argc, char **argv)
if (tp->th_opcode == RRQ || tp->th_opcode == WRQ) { if (tp->th_opcode == RRQ || tp->th_opcode == WRQ) {
memset(&test, 0, sizeof(test)); memset(&test, 0, sizeof(test));
server = fopen(REQUEST_DUMP, "ab"); server = fopen(REQUEST_DUMP, "ab");
if(!server) if(!server) {
error = ERRNO;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", REQUEST_DUMP);
break; break;
}
test.server = server; test.server = server;
tftp(&test, tp, n); tftp(&test, tp, n);
if(test.buffer) if(test.buffer)
@ -645,6 +654,7 @@ static int validate_access(struct testcase *test,
{ {
char *ptr; char *ptr;
long testno; long testno;
int error;
logmsg("trying to get file: %s mode %x", filename, mode); logmsg("trying to get file: %s mode %x", filename, mode);
@ -684,6 +694,9 @@ static int validate_access(struct testcase *test,
if(file) { if(file) {
FILE *stream=fopen(file, "rb"); FILE *stream=fopen(file, "rb");
if(!stream) { if(!stream) {
error = ERRNO;
logmsg("fopen() failed with error: %d %s", error, strerror(error));
logmsg("Error opening file: %s", file);
logmsg("Couldn't open test file: %s", file); logmsg("Couldn't open test file: %s", file);
return EACCESS; return EACCESS;
} }

View File

@ -130,7 +130,7 @@ void win32_init(void)
if (err != 0) { if (err != 0) {
perror("Winsock init failed"); perror("Winsock init failed");
logmsg("Error initialising winsock -- aborting\n"); logmsg("Error initialising winsock -- aborting");
exit(1); exit(1);
} }
@ -139,7 +139,7 @@ void win32_init(void)
WSACleanup(); WSACleanup();
perror("Winsock init failed"); perror("Winsock init failed");
logmsg("No suitable winsock.dll found -- aborting\n"); logmsg("No suitable winsock.dll found -- aborting");
exit(1); exit(1);
} }
} }