void RequestProcessor::process(PacketWrapper *wrapper) { if (wrapper == NULL) { log_error("wrapper is null."); } else { int pcode = wrapper->get_packet()->getPCode(); switch (pcode) { case TAIR_REQ_INVAL_PACKET: { do_process_request(&tair_client_impl::remove, wrapper); break; } case TAIR_REQ_HIDE_BY_PROXY_PACKET: { do_process_request(&tair_client_impl::hide, wrapper); break; } case TAIR_REQ_PREFIX_HIDES_BY_PROXY_PACKET: { do_process_request(&tair_client_impl::hides, wrapper); break; } case TAIR_REQ_PREFIX_INVALIDS_PACKET: { do_process_request(&tair_client_impl::removes, wrapper); break; } default: log_error("unknown pakcet, pcode: %d", pcode); } } }
static int do_read_request(client_ctx *cx) { conn *incoming; size_t size; incoming = &cx->incoming; if (incoming->result < 0) { pr_err("read error: %s", uv_strerror(incoming->result)); return do_kill(cx); } size = (size_t)incoming->offset; if (size >= (size_t)incoming->req_size + 2) { return do_process_request(cx); } else { conn_read(incoming); } return s_read_request; }
ClassAd * process_request(const ClassAd *inputAd) { static unsigned int req_number = 0; // Number each new request. ClassAd *resultAd = new ClassAd(); ASSERT(resultAd); resultAd->Assign("REQUEST_NUMBER",++req_number); dprintf(D_ALWAYS,"----------------------------------------\nProcessing request %d\n",req_number); dprintf(D_FULLDEBUG,"Contents of request classad:\n"); if ( inputAd ) { dPrintAd(D_FULLDEBUG, *(ClassAd*)inputAd); } // Create two temp dirs, one to serve as the iwd for the command, another // to hold the stdout/err. char *iwd = create_temp_file(true); char *stdio_iwd = create_temp_file(true); if (!iwd || !stdio_iwd) { handle_process_request_error("failed to create temp dirs",req_number,resultAd); return resultAd; } // Do the work. do_process_request(inputAd, resultAd, req_number, iwd, stdio_iwd); // Blow away our temp dirs unless we are in debug mode bool debug_mode = param_boolean("SOAPSHELL_DEBUG_MODE",false); if ( !debug_mode ) { if ( iwd ) { Directory dir(iwd); dir.Remove_Full_Path(iwd); free(iwd); } if ( stdio_iwd ) { Directory dir(stdio_iwd); dir.Remove_Full_Path(stdio_iwd); free(stdio_iwd); } } else { if ( iwd ) { dprintf(D_ALWAYS,"SOAPSHELL_DEBUG_MODE=True so not removing iwd %s\n", iwd); free(iwd); } if ( stdio_iwd ) { dprintf(D_ALWAYS,"SOAPSHELL_DEBUG_MODE=True so not removing stdio_iwd %s\n", stdio_iwd); free(stdio_iwd); } } dprintf(D_FULLDEBUG,"Contents of result classad:\n"); dPrintAd(D_FULLDEBUG, *resultAd); dprintf(D_ALWAYS,"Finished processing request %d\n",req_number); return resultAd; }