mirror of
https://github.com/curl/curl.git
synced 2024-11-27 05:50:21 +08:00
add debug messages for initialization failures
This commit is contained in:
parent
cbf58d88d0
commit
31e598d2f3
@ -224,6 +224,7 @@ static int file_lookup(union ares_addr *addr, int family, struct hostent **host)
|
||||
switch(error)
|
||||
{
|
||||
case ENOENT:
|
||||
case ESRCH:
|
||||
return ARES_ENOTFOUND;
|
||||
default:
|
||||
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||
|
@ -248,6 +248,7 @@ static int file_lookup(const char *name, int family, struct hostent **host)
|
||||
FILE *fp;
|
||||
char **alias;
|
||||
int status;
|
||||
int error;
|
||||
|
||||
#ifdef WIN32
|
||||
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");
|
||||
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)
|
||||
{
|
||||
if (strcasecmp((*host)->h_name, name) == 0)
|
||||
|
@ -639,6 +639,7 @@ DhcpNameServer
|
||||
error = ERRNO;
|
||||
switch(error) {
|
||||
case ENOENT:
|
||||
case ESRCH:
|
||||
status = ARES_EOF;
|
||||
break;
|
||||
default:
|
||||
@ -664,6 +665,7 @@ DhcpNameServer
|
||||
error = ERRNO;
|
||||
switch(error) {
|
||||
case ENOENT:
|
||||
case ESRCH:
|
||||
status = ARES_EOF;
|
||||
break;
|
||||
default:
|
||||
@ -690,6 +692,7 @@ DhcpNameServer
|
||||
error = ERRNO;
|
||||
switch(error) {
|
||||
case ENOENT:
|
||||
case ESRCH:
|
||||
status = ARES_EOF;
|
||||
break;
|
||||
default:
|
||||
@ -716,6 +719,7 @@ DhcpNameServer
|
||||
error = ERRNO;
|
||||
switch(error) {
|
||||
case ENOENT:
|
||||
case ESRCH:
|
||||
status = ARES_EOF;
|
||||
break;
|
||||
default:
|
||||
|
@ -273,6 +273,7 @@ static int single_domain(ares_channel channel, const char *name, char **s)
|
||||
switch(error)
|
||||
{
|
||||
case ENOENT:
|
||||
case ESRCH:
|
||||
break;
|
||||
default:
|
||||
DEBUGF(fprintf(stderr, "fopen() failed with error: %d %s\n",
|
||||
|
@ -353,7 +353,7 @@ static int juggle(curl_socket_t *sockfdp,
|
||||
client connecting. */
|
||||
sockfd = accept(sockfd, NULL, NULL);
|
||||
if(CURL_SOCKET_BAD == sockfd)
|
||||
logmsg("accept() failed\n");
|
||||
logmsg("accept() failed");
|
||||
else {
|
||||
logmsg("====> Client connect");
|
||||
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,
|
||||
&socksize)<0) {
|
||||
fprintf(stderr, "getsockname() failed");
|
||||
logmsg("getsockname() failed with error: %d", SOCKERRNO);
|
||||
return CURL_SOCKET_BAD;
|
||||
}
|
||||
*port = ntohs(add.sin_port);
|
||||
@ -489,6 +489,7 @@ int main(int argc, char *argv[])
|
||||
FILE *pidfile;
|
||||
char *pidname= (char *)".sockfilt.pid";
|
||||
int rc;
|
||||
int error;
|
||||
int arg=1;
|
||||
enum sockmode mode = PASSIVE_LISTEN; /* default */
|
||||
|
||||
@ -631,7 +632,10 @@ int main(int argc, char *argv[])
|
||||
logmsg("Wrote pid %d to %s", pid, pidname);
|
||||
}
|
||||
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);
|
||||
return 1;
|
||||
}
|
||||
|
@ -197,6 +197,7 @@ int ProcessRequest(struct httprequest *req)
|
||||
char logbuf[256];
|
||||
int prot_major, prot_minor;
|
||||
char *end;
|
||||
int error;
|
||||
end = strstr(line, END_OF_HEADERS);
|
||||
|
||||
logmsg("ProcessRequest() called");
|
||||
@ -263,6 +264,9 @@ int ProcessRequest(struct httprequest *req)
|
||||
|
||||
stream=fopen(filename, "rb");
|
||||
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);
|
||||
req->open = FALSE; /* closes connection */
|
||||
return 1; /* done */
|
||||
@ -569,6 +573,7 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
|
||||
FILE *dump;
|
||||
int persistant = TRUE;
|
||||
size_t responsesize;
|
||||
int error;
|
||||
|
||||
static char weare[256];
|
||||
|
||||
@ -646,6 +651,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
|
||||
|
||||
stream=fopen(filename, "rb");
|
||||
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");
|
||||
return 0;
|
||||
}
|
||||
@ -658,6 +666,9 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
|
||||
/* re-open the same file again */
|
||||
stream=fopen(filename, "rb");
|
||||
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");
|
||||
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 */
|
||||
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);
|
||||
return -1;
|
||||
}
|
||||
@ -872,7 +886,10 @@ int main(int argc, char *argv[])
|
||||
fclose(pidfile);
|
||||
}
|
||||
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);
|
||||
return 1;
|
||||
}
|
||||
|
@ -424,6 +424,7 @@ int main(int argc, char **argv)
|
||||
curl_socket_t sock;
|
||||
int flag;
|
||||
int rc;
|
||||
int error;
|
||||
struct testcase test;
|
||||
|
||||
while(argc>arg) {
|
||||
@ -513,8 +514,12 @@ int main(int argc, char **argv)
|
||||
fprintf(pidfile, "%d\n", (int)getpid());
|
||||
fclose(pidfile);
|
||||
}
|
||||
else
|
||||
fprintf(stderr, "Couldn't write pid file\n");
|
||||
else {
|
||||
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",
|
||||
#ifdef ENABLE_IPV6
|
||||
@ -554,8 +559,12 @@ int main(int argc, char **argv)
|
||||
if (tp->th_opcode == RRQ || tp->th_opcode == WRQ) {
|
||||
memset(&test, 0, sizeof(test));
|
||||
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;
|
||||
}
|
||||
test.server = server;
|
||||
tftp(&test, tp, n);
|
||||
if(test.buffer)
|
||||
@ -645,6 +654,7 @@ static int validate_access(struct testcase *test,
|
||||
{
|
||||
char *ptr;
|
||||
long testno;
|
||||
int error;
|
||||
|
||||
logmsg("trying to get file: %s mode %x", filename, mode);
|
||||
|
||||
@ -684,6 +694,9 @@ static int validate_access(struct testcase *test,
|
||||
if(file) {
|
||||
FILE *stream=fopen(file, "rb");
|
||||
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);
|
||||
return EACCESS;
|
||||
}
|
||||
|
@ -130,7 +130,7 @@ void win32_init(void)
|
||||
|
||||
if (err != 0) {
|
||||
perror("Winsock init failed");
|
||||
logmsg("Error initialising winsock -- aborting\n");
|
||||
logmsg("Error initialising winsock -- aborting");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
@ -139,7 +139,7 @@ void win32_init(void)
|
||||
|
||||
WSACleanup();
|
||||
perror("Winsock init failed");
|
||||
logmsg("No suitable winsock.dll found -- aborting\n");
|
||||
logmsg("No suitable winsock.dll found -- aborting");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user