static void globus_l_xio_telnet_cmd_write_cb( globus_xio_operation_t op, globus_result_t result, globus_size_t nbytes, void * user_arg) { globus_l_xio_telnet_handle_t * handle; handle = (globus_l_xio_telnet_handle_t *) user_arg; if(result != GLOBUS_SUCCESS) { globus_xio_driver_finished_read(op, result, 0); return; } globus_mutex_lock(&handle->mutex); { globus_free(handle->write_iovec.iov_base); globus_l_xio_telnet_request_data(handle, op); } globus_mutex_unlock(&handle->mutex); if(handle->finish) { handle->finish = GLOBUS_FALSE; globus_xio_driver_finished_read( op, handle->finish_res, handle->finish_len); } }
static void globus_l_xio_telnet_read_cb( globus_xio_operation_t op, globus_result_t result, globus_size_t nbytes, void * user_arg) { globus_l_xio_telnet_handle_t * handle; handle = (globus_l_xio_telnet_handle_t *) user_arg; if(result != GLOBUS_SUCCESS) { globus_xio_driver_finished_read(op, result, nbytes); return; } globus_mutex_lock(&handle->mutex); { handle->read_buffer_ndx += nbytes; globus_l_xio_telnet_request_data(handle, op); } globus_mutex_unlock(&handle->mutex); if(handle->finish) { handle->finish = GLOBUS_FALSE; globus_xio_driver_finished_read( op, handle->finish_res, handle->finish_len); } }
static globus_result_t globus_l_xio_telnet_read( void * driver_specific_handle, const globus_xio_iovec_t * iovec, int iovec_count, globus_xio_operation_t op) { globus_l_xio_telnet_handle_t * handle; handle = (globus_l_xio_telnet_handle_t *) driver_specific_handle; globus_mutex_lock(&handle->mutex); { handle->user_read_iovec = (globus_xio_iovec_t *) iovec; handle->user_read_iovec_count = iovec_count; globus_l_xio_telnet_request_data(handle, op); } globus_mutex_unlock(&handle->mutex); if(handle->finish) { handle->finish = GLOBUS_FALSE; globus_xio_driver_finished_read( op, handle->finish_res, handle->finish_len); } return GLOBUS_SUCCESS; }
static void globus_l_xio_popen_system_read_cb( globus_result_t result, globus_size_t nbytes, void * user_arg) { globus_xio_operation_t op; xio_l_popen_handle_t * handle; GlobusXIOName(globus_l_xio_popen_system_read_cb); GlobusXIOPOpenDebugEnter(); op = (globus_xio_operation_t) user_arg; handle = (xio_l_popen_handle_t *) globus_xio_operation_get_driver_specific(op); handle->canceled = globus_xio_operation_is_canceled(op); globus_l_xio_popen_update_position( handle, nbytes, SEEK_CUR); globus_xio_driver_finished_read(op, result, nbytes); GlobusXIOPOpenDebugExit(); }
/* * read from a file */ static globus_result_t globus_l_xio_popen_read( void * driver_specific_handle, const globus_xio_iovec_t * iovec, int iovec_count, globus_xio_operation_t op) { xio_l_popen_handle_t * handle; globus_size_t nbytes; globus_result_t result; globus_off_t offset; GlobusXIOName(globus_l_xio_popen_read); GlobusXIOPOpenDebugEnter(); handle = (xio_l_popen_handle_t *) driver_specific_handle; offset = GlobusXIOPOpenPosition(handle); /* if buflen and waitfor are both 0, we behave like register select */ if((globus_xio_operation_get_wait_for(op) == 0 && (iovec_count > 1 || iovec[0].iov_len > 0)) || (handle->use_blocking_io && globus_xio_driver_operation_is_blocking(op))) { result = globus_xio_system_file_read( handle->in_system, offset, iovec, iovec_count, globus_xio_operation_get_wait_for(op), &nbytes); globus_l_xio_popen_update_position(handle, nbytes, SEEK_CUR); globus_xio_driver_finished_read(op, result, nbytes); result = GLOBUS_SUCCESS; } else { result = globus_xio_system_file_register_read( op, handle->in_system, offset, iovec, iovec_count, globus_xio_operation_get_wait_for(op), globus_l_xio_popen_system_read_cb, op); } GlobusXIOPOpenDebugExit(); return result; }
static globus_result_t globus_l_xio_wrapblock_read( void * driver_specific_handle, const globus_xio_iovec_t * iovec, int iovec_count, globus_xio_operation_t op) { globus_size_t nbytes; globus_result_t result; int i; xio_l_wrapblock_wrapper_t * wrapper; xio_l_wrapblock_handle_t * wrapblock_handle; wrapblock_handle = (xio_l_wrapblock_handle_t *) driver_specific_handle; if(globus_xio_driver_operation_is_blocking(op)) { result = wrapblock_handle->wrapblock_driver->read_func( wrapblock_handle->driver_handle, iovec, iovec_count, &nbytes); globus_xio_driver_finished_read(op, result, nbytes); } else { wrapper = (xio_l_wrapblock_wrapper_t *) globus_calloc(1, sizeof(xio_l_wrapblock_wrapper_t)); wrapper->iovec = (globus_xio_iovec_t *) globus_calloc(iovec_count, sizeof(globus_xio_iovec_t)); wrapper->iovec_count = iovec_count; wrapper->op = op; wrapper->wrapblock_handle = driver_specific_handle; for(i = 0; i < iovec_count; i++) { wrapper->iovec[i].iov_base = iovec[i].iov_base; wrapper->iovec[i].iov_len = iovec[i].iov_len; } globus_callback_register_oneshot( NULL, NULL, globus_l_xio_wrapblock_read_kickout, wrapper); } return GLOBUS_SUCCESS; }
static void globus_l_xio_pipe_system_read_cb( globus_result_t result, globus_size_t nbytes, void * user_arg) { globus_xio_operation_t op; GlobusXIOName(globus_l_xio_pipe_system_read_cb); GlobusXIOPipeDebugEnter(); op = (globus_xio_operation_t) user_arg; globus_xio_driver_finished_read(op, result, nbytes); GlobusXIOPipeDebugExit(); }
static void test_bounce_finish_op( bounce_info_t * info, globus_xio_operation_t op) { GlobusXIOName(test_bounce_finish_op); GlobusXIOTestDebugInternalEnter(); switch(info->start_op) { case TEST_READ: globus_xio_driver_finished_read(op, info->res, info->nbytes); break; case TEST_WRITE: globus_xio_driver_finished_write(op, info->res, info->nbytes); break; case TEST_OPEN: if(info->res != GLOBUS_SUCCESS) { bounce_handle_destroy(info->handle); info->handle = NULL; } globus_xio_driver_finished_open( info->handle, op, info->res); break; case TEST_CLOSE: globus_xio_driver_finished_close(op, info->res); bounce_handle_destroy(info->handle); break; default: globus_assert(0); break; } globus_free(info); GlobusXIOTestDebugInternalExit(); }
static void globus_l_xio_wrapblock_read_kickout( void * user_arg) { globus_size_t nbytes; globus_result_t result; xio_l_wrapblock_wrapper_t * wrapper; globus_thread_blocking_will_block(); wrapper = (xio_l_wrapblock_wrapper_t *) user_arg; result = wrapper->wrapblock_handle->wrapblock_driver->read_func( wrapper->wrapblock_handle->driver_handle, wrapper->iovec, wrapper->iovec_count, &nbytes); globus_xio_driver_finished_read(wrapper->op, result, nbytes); xio_l_wrapblock_wrapper_destroy(wrapper); }
void globus_i_xio_http_server_read_request_callback( globus_xio_operation_t op, globus_result_t result, globus_size_t nbytes, void * user_arg) { globus_i_xio_http_handle_t * http_handle = user_arg; globus_bool_t done; globus_result_t eof_result = GLOBUS_SUCCESS; globus_i_xio_http_attr_t * descriptor; globus_bool_t registered_again = GLOBUS_FALSE; GlobusXIOName(globus_i_xio_http_server_read_request_callback); globus_mutex_lock(&http_handle->mutex); if (result != GLOBUS_SUCCESS) { if (globus_xio_error_is_eof(result)) { eof_result = result; } else { goto error_exit; } } /* Haven't parsed request and headers yet */ http_handle->read_buffer_valid += nbytes; result = globus_l_xio_http_server_parse_request(http_handle, &done); if (result == GLOBUS_SUCCESS && !done) { goto reregister_read; } else if (result != GLOBUS_SUCCESS) { goto error_exit; } /* Determine whether we should expect an entity along with the * request */ if ((http_handle->request_info.http_version == GLOBUS_XIO_HTTP_VERSION_1_1) && (http_handle->request_info.headers.transfer_encoding == GLOBUS_XIO_HTTP_TRANSFER_ENCODING_CHUNKED)) { http_handle->parse_state = GLOBUS_XIO_HTTP_CHUNK_LINE; } else if (GLOBUS_I_XIO_HTTP_HEADER_IS_CONTENT_LENGTH_SET( &http_handle->request_info.headers)) { http_handle->parse_state = GLOBUS_XIO_HTTP_IDENTITY_BODY; } if (GLOBUS_I_XIO_HTTP_HEADER_IS_CONNECTION_CLOSE( &http_handle->request_info.headers)) { http_handle->response_info.headers.flags |= GLOBUS_I_XIO_HTTP_HEADER_CONNECTION_CLOSE; } http_handle->send_state = GLOBUS_XIO_HTTP_STATUS_LINE; descriptor = globus_xio_operation_get_data_descriptor(op, GLOBUS_TRUE); if (descriptor == NULL) { result = GlobusXIOErrorMemory("descriptor"); goto error_exit; } globus_i_xio_http_request_destroy(&descriptor->request); result = globus_i_xio_http_request_copy( &descriptor->request, &http_handle->request_info); if (result != GLOBUS_SUCCESS) { goto error_exit; } result = globus_i_xio_http_parse_residue(http_handle, ®istered_again); if ((http_handle->read_operation.wait_for <= 0 && !registered_again) || result != GLOBUS_SUCCESS) { if (http_handle->response_info.headers.transfer_encoding != GLOBUS_XIO_HTTP_TRANSFER_ENCODING_CHUNKED && GLOBUS_I_XIO_HTTP_HEADER_IS_CONTENT_LENGTH_SET( &http_handle->response_info.headers) && http_handle->response_info.headers.content_length == 0) { /* Synthesize EOF if we've read all of the entity content */ result = GlobusXIOErrorEOF(); } /* * Either we've read enough, hit end of chunk, no entity was present, * or pass to transport failed. Call finished_read */ nbytes = http_handle->read_operation.nbytes; globus_libc_free(http_handle->read_operation.iov); http_handle->read_operation.iov = NULL; http_handle->read_operation.iovcnt = 0; http_handle->read_operation.operation = NULL; http_handle->read_operation.driver_handle = NULL; http_handle->read_operation.nbytes = 0; globus_mutex_unlock(&http_handle->mutex); globus_xio_driver_finished_read(op, result, nbytes); return; } else if (registered_again) { globus_mutex_unlock(&http_handle->mutex); return; } /* FALLSTHROUGH */ reregister_read: globus_assert(op == http_handle->read_operation.operation); if (eof_result != GLOBUS_SUCCESS) { /* Header block wasn't complete before eof */ result = eof_result; goto error_exit; } result = globus_i_xio_http_clean_read_buffer(http_handle); if (result != GLOBUS_SUCCESS) { goto error_exit; } result = globus_xio_driver_pass_read( op, &http_handle->read_iovec, 1, 1, globus_i_xio_http_server_read_request_callback, http_handle); if (result != GLOBUS_SUCCESS) { goto error_exit; } globus_mutex_unlock(&http_handle->mutex); return; error_exit: globus_libc_free(http_handle->read_operation.iov); http_handle->read_operation.iov = NULL; http_handle->read_operation.iovcnt = 0; http_handle->read_operation.operation = NULL; http_handle->read_operation.driver_handle = NULL; http_handle->read_operation.nbytes = 0; globus_mutex_unlock(&http_handle->mutex); globus_xio_driver_finished_read(op, result, 0); }