void ccnet_processor_send_error_update (CcnetProcessor *processor, const char *code, const char *code_msg) { ccnet_peer_send_update (processor->peer, UPDATE_ID(processor->id), code, code_msg, NULL, 0); }
void ccnet_processor_send_update (CcnetProcessor *processor, const char *code, const char *code_msg, const char *content, int clen) { ccnet_peer_send_update (processor->peer, UPDATE_ID(processor->id), code, code_msg, content, clen); }
static void handle_response (CcnetPeer *peer, int req_id, char *data, int len) { CcnetProcessor *processor; char *code, *code_msg = 0, *content = 0; int clen; char *ptr, *end; if (len < 4) goto error; code = data; ptr = data + 3; if (*ptr == '\n') { /* no code_msg */ *ptr++ = '\0'; content = ptr; clen = len - (ptr - data); goto parsed; } if (*ptr != ' ') goto error; *ptr++ = '\0'; code_msg = ptr; end = data + len; for (ptr = data; *ptr != '\n' && ptr != end; ptr++) ; if (ptr == end) /* must end with '\n' */ goto error; /* if (*(ptr-1) == '\r') */ /* *(ptr-1) = '\0'; */ *ptr++ = '\0'; content = ptr; clen = len - (ptr - data); parsed: processor = ccnet_peer_get_processor (peer, MASTER_ID (req_id)); if (processor == NULL) { /* do nothing if receiving SC_PROC_DEAD and the processor on * this side is also not present. Otherwise send SC_PROC_DEAD */ if (memcmp(code, SC_PROC_DEAD, 3) != 0) { ccnet_debug ("Delayed response from %s(%.10s), id is %d, %s %s\n", peer->name, peer->id, req_id, code, code_msg); ccnet_peer_send_update (peer, req_id, SC_PROC_DEAD, SS_PROC_DEAD, NULL, 0); } return; } /* if (!peer->is_local) */ /* ccnet_debug ("[RECV] handle_response %s id is %d, %s %s\n", */ /* GET_PNAME(processor), PRINT_ID(processor->id), */ /* code, code_msg); */ peer->in_processor_call = 1; ccnet_processor_handle_response (processor, code, code_msg, content, clen); peer->in_processor_call = 0; return; error: ccnet_warning ("Bad response format from %s\n", peer->id); }