diff options
author | Roger Dingledine <arma@torproject.org> | 2003-09-26 10:03:50 +0000 |
---|---|---|
committer | Roger Dingledine <arma@torproject.org> | 2003-09-26 10:03:50 +0000 |
commit | 9e5cafc395397426030e8098d64b8e25625863c5 (patch) | |
tree | a92b2c34d62a5673746387e1b10e42788e1838ef /src/or/cpuworker.c | |
parent | db2684149eb0b1528e0b545303ad4db69a0ed584 (diff) | |
download | tor-9e5cafc395397426030e8098d64b8e25625863c5.tar.gz tor-9e5cafc395397426030e8098d64b8e25625863c5.zip |
first pass: obey log convention
ERR is if something fatal just happened
WARNING is something bad happened, but we're still running. The bad thing
is either a bug in the code, an attack or buggy protocol/implementation
of the remote peer, etc. The operator should examine the bad thing and
try to correct it.
(No error or warning messages should be expected. I expect most people
to run on -l warning eventually.)
NOTICE is never ever used.
INFO means something happened (maybe bad, maybe ok), but there's nothing
you need to (or can) do about it.
DEBUG is for everything louder than INFO.
svn:r486
Diffstat (limited to 'src/or/cpuworker.c')
-rw-r--r-- | src/or/cpuworker.c | 35 |
1 files changed, 15 insertions, 20 deletions
diff --git a/src/or/cpuworker.c b/src/or/cpuworker.c index d3d945e7e6..b67e4ca8ff 100644 --- a/src/or/cpuworker.c +++ b/src/or/cpuworker.c @@ -31,14 +31,9 @@ int connection_cpu_finished_flushing(connection_t *conn) { } static void tag_pack(char *tag, uint32_t addr, uint16_t port, aci_t aci) { - struct in_addr in; - *(uint32_t *)tag = addr; *(uint16_t *)(tag+4) = port; *(aci_t *)(tag+6) = aci; - - in.s_addr = htonl(addr); - log_fn(LOG_DEBUG,"onion was from %s:%d, aci %d.", inet_ntoa(in), port, aci); } static void tag_unpack(char *tag, uint32_t *addr, uint16_t *port, aci_t *aci) { @@ -63,7 +58,7 @@ int connection_cpu_process_inbuf(connection_t *conn) { assert(conn && conn->type == CONN_TYPE_CPUWORKER); if(conn->inbuf_reached_eof) { - log_fn(LOG_ERR,"Read eof. Worker dying."); + log_fn(LOG_WARNING,"Read eof. Worker dying."); if(conn->state != CPUWORKER_STATE_IDLE) { /* XXX the circ associated with this cpuworker will wait forever. Oops. */ num_cpuworkers_busy--; @@ -87,17 +82,17 @@ int connection_cpu_process_inbuf(connection_t *conn) { circ = circuit_get_by_aci_conn(aci, p_conn); if(!circ) { - log_fn(LOG_DEBUG,"processed onion for a circ that's gone. Dropping."); + log_fn(LOG_INFO,"processed onion for a circ that's gone. Dropping."); goto done_processing; } assert(circ->p_conn); if(*buf == 0) { - log_fn(LOG_DEBUG,"decoding onionskin failed. Closing."); + log_fn(LOG_WARNING,"decoding onionskin failed. Closing."); circuit_close(circ); goto done_processing; } if(onionskin_answer(circ, buf+1+TAG_LEN, buf+1+TAG_LEN+DH_KEY_LEN) < 0) { - log_fn(LOG_DEBUG,"onionskin_answer failed. Closing."); + log_fn(LOG_WARNING,"onionskin_answer failed. Closing."); circuit_close(circ); goto done_processing; } @@ -131,18 +126,18 @@ int cpuworker_main(void *data) { for(;;) { if(read(fd, &question_type, 1) != 1) { - log_fn(LOG_INFO,"read type failed. Exiting."); + log_fn(LOG_ERR,"read type failed. Exiting."); spawn_exit(); } assert(question_type == CPUWORKER_TASK_ONION); if(read_all(fd, tag, TAG_LEN) != TAG_LEN) { - log_fn(LOG_INFO,"read tag failed. Exiting."); + log_fn(LOG_ERR,"read tag failed. Exiting."); spawn_exit(); } if(read_all(fd, question, DH_ONIONSKIN_LEN) != DH_ONIONSKIN_LEN) { - log_fn(LOG_INFO,"read question failed. Exiting."); + log_fn(LOG_ERR,"read question failed. Exiting."); spawn_exit(); } @@ -150,18 +145,18 @@ int cpuworker_main(void *data) { if(onion_skin_server_handshake(question, get_onion_key(), reply_to_proxy, keys, 32) < 0) { /* failure */ - log_fn(LOG_ERR,"onion_skin_server_handshake failed."); + log_fn(LOG_WARNING,"onion_skin_server_handshake failed."); memset(buf,0,LEN_ONION_RESPONSE); /* send all zeros for failure */ } else { /* success */ - log_fn(LOG_DEBUG,"onion_skin_server_handshake succeeded."); + log_fn(LOG_INFO,"onion_skin_server_handshake succeeded."); buf[0] = 1; /* 1 means success */ memcpy(buf+1,tag,TAG_LEN); memcpy(buf+1+TAG_LEN,reply_to_proxy,DH_KEY_LEN); memcpy(buf+1+TAG_LEN+DH_KEY_LEN,keys,32); } if(write_all(fd, buf, LEN_ONION_RESPONSE) != LEN_ONION_RESPONSE) { - log_fn(LOG_INFO,"writing response buf failed. Exiting."); + log_fn(LOG_ERR,"writing response buf failed. Exiting."); spawn_exit(); } log_fn(LOG_DEBUG,"finished writing response."); @@ -198,7 +193,7 @@ static int spawn_cpuworker(void) { conn->address = strdup("localhost"); if(connection_add(conn) < 0) { /* no space, forget it */ - log_fn(LOG_INFO,"connection_add failed. Giving up."); + log_fn(LOG_WARNING,"connection_add failed. Giving up."); connection_free(conn); /* this closes fd[0] */ return -1; } @@ -219,7 +214,7 @@ static void spawn_enough_cpuworkers(void) { while(num_cpuworkers < num_cpuworkers_needed) { if(spawn_cpuworker() < 0) { - log_fn(LOG_ERR,"spawn failed!"); + log_fn(LOG_WARNING,"spawn failed!"); return; } num_cpuworkers++; @@ -238,7 +233,7 @@ static void process_pending_task(connection_t *cpuworker) { if(!circ) return; if(assign_to_cpuworker(cpuworker, CPUWORKER_TASK_ONION, circ) < 0) - log_fn(LOG_DEBUG,"assign_to_cpuworker failed. Ignoring."); + log_fn(LOG_WARNING,"assign_to_cpuworker failed. Ignoring."); } /* if cpuworker is defined, assert that he's idle, and use him. else, @@ -270,7 +265,7 @@ int assign_to_cpuworker(connection_t *cpuworker, unsigned char question_type, assert(cpuworker); if(!circ->p_conn) { - log_fn(LOG_DEBUG,"circ->p_conn gone. Failing circ."); + log_fn(LOG_INFO,"circ->p_conn gone. Failing circ."); return -1; } tag_pack(tag, circ->p_conn->addr, circ->p_conn->port, circ->p_aci); @@ -281,7 +276,7 @@ int assign_to_cpuworker(connection_t *cpuworker, unsigned char question_type, if(connection_write_to_buf(&question_type, 1, cpuworker) < 0 || connection_write_to_buf(tag, sizeof(tag), cpuworker) < 0 || connection_write_to_buf(circ->onionskin, DH_ONIONSKIN_LEN, cpuworker) < 0) { - log_fn(LOG_NOTICE,"Write failed. Closing worker and failing circ."); + log_fn(LOG_WARNING,"Write failed. Closing worker and failing circ."); cpuworker->marked_for_close = 1; return -1; } |