socket_buckets.c | socket_buckets.c | |||
---|---|---|---|---|
skipping to change at line 20 | skipping to change at line 20 | |||
* distributed under the License is distributed on an "AS IS" BASIS, | * distributed under the License is distributed on an "AS IS" BASIS, | |||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||
* See the License for the specific language governing permissions and | * See the License for the specific language governing permissions and | |||
* limitations under the License. | * limitations under the License. | |||
*/ | */ | |||
#include <apr_pools.h> | #include <apr_pools.h> | |||
#include <apr_network_io.h> | #include <apr_network_io.h> | |||
#include "serf.h" | #include "serf.h" | |||
#include "serf_private.h" | ||||
#include "serf_bucket_util.h" | #include "serf_bucket_util.h" | |||
typedef struct { | typedef struct { | |||
apr_socket_t *skt; | apr_socket_t *skt; | |||
serf_databuf_t databuf; | serf_databuf_t databuf; | |||
/* Progress callback */ | /* Progress callback */ | |||
serf_progress_t progress_func; | serf_progress_t progress_func; | |||
void *progress_baton; | void *progress_baton; | |||
skipping to change at line 41 | skipping to change at line 42 | |||
static apr_status_t socket_reader(void *baton, apr_size_t bufsize, | static apr_status_t socket_reader(void *baton, apr_size_t bufsize, | |||
char *buf, apr_size_t *len) | char *buf, apr_size_t *len) | |||
{ | { | |||
socket_context_t *ctx = baton; | socket_context_t *ctx = baton; | |||
apr_status_t status; | apr_status_t status; | |||
*len = bufsize; | *len = bufsize; | |||
status = apr_socket_recv(ctx->skt, buf, len); | status = apr_socket_recv(ctx->skt, buf, len); | |||
if (status && !APR_STATUS_IS_EAGAIN(status)) | ||||
serf__log_skt(SOCK_VERBOSE, __FILE__, ctx->skt, | ||||
"socket_recv error %d\n", status); | ||||
if (*len) | ||||
serf__log_skt(SOCK_MSG_VERBOSE, __FILE__, ctx->skt, | ||||
"--- socket_recv:\n%.*s\n-(%d)-\n", | ||||
*len, buf, *len); | ||||
if (ctx->progress_func) | if (ctx->progress_func) | |||
ctx->progress_func(ctx->progress_baton, *len, 0); | ctx->progress_func(ctx->progress_baton, *len, 0); | |||
return status; | return status; | |||
} | } | |||
serf_bucket_t *serf_bucket_socket_create( | serf_bucket_t *serf_bucket_socket_create( | |||
apr_socket_t *skt, | apr_socket_t *skt, | |||
serf_bucket_alloc_t *allocator) | serf_bucket_alloc_t *allocator) | |||
{ | { | |||
socket_context_t *ctx; | socket_context_t *ctx; | |||
/* Oh, well. */ | /* Oh, well. */ | |||
ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); | ctx = serf_bucket_mem_alloc(allocator, sizeof(*ctx)); | |||
ctx->skt = skt; | ctx->skt = skt; | |||
serf_databuf_init(&ctx->databuf); | serf_databuf_init(&ctx->databuf); | |||
ctx->databuf.read = socket_reader; | ctx->databuf.read = socket_reader; | |||
ctx->databuf.read_baton = ctx; | ctx->databuf.read_baton = ctx; | |||
ctx->progress_func = ctx->progress_baton = NULL; | ctx->progress_func = NULL; | |||
ctx->progress_baton = NULL; | ||||
return serf_bucket_create(&serf_bucket_type_socket, allocator, ctx); | return serf_bucket_create(&serf_bucket_type_socket, allocator, ctx); | |||
} | } | |||
void serf_bucket_socket_set_read_progress_cb( | void serf_bucket_socket_set_read_progress_cb( | |||
serf_bucket_t *bucket, | serf_bucket_t *bucket, | |||
const serf_progress_t progress_func, | const serf_progress_t progress_func, | |||
void *progress_baton) | void *progress_baton) | |||
{ | { | |||
socket_context_t *ctx = bucket->data; | socket_context_t *ctx = bucket->data; | |||
End of changes. 3 change blocks. | ||||
1 lines changed or deleted | 12 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |