Changeset 2187
- Timestamp:
- Aug 4, 2008 9:59:02 AM (16 years ago)
- Location:
- pjproject/trunk/pjlib
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
pjproject/trunk/pjlib/include/pj/activesock.h
r2185 r2187 357 357 358 358 /** 359 * Same as #pj_activesock_start_read(), except that the application 360 * supplies the buffers for the read operation so that the acive socket 361 * does not have to allocate the buffers. 362 * 363 * @param asock The active socket. 364 * @param pool Pool used to allocate buffers for incoming data. 365 * @param buff_size The size of each buffer, in bytes. 366 * @param readbuf Array of packet buffers, each has buff_size size. 367 * @param flags Flags to be given to pj_ioqueue_recv(). 368 * 369 * @return PJ_SUCCESS if the operation has been successful, 370 * or the appropriate error code on failure. 371 */ 372 PJ_DECL(pj_status_t) pj_activesock_start_read2(pj_activesock_t *asock, 373 pj_pool_t *pool, 374 unsigned buff_size, 375 void *readbuf[], 376 pj_uint32_t flags); 377 378 /** 359 379 * Same as pj_activesock_start_read(), except that this function is used 360 380 * only for datagram sockets, and it will trigger \a on_data_recvfrom() … … 373 393 unsigned buff_size, 374 394 pj_uint32_t flags); 395 396 /** 397 * Same as #pj_activesock_start_recvfrom() except that the recvfrom() 398 * operation takes the buffer from the argument rather than creating 399 * new ones. 400 * 401 * @param asock The active socket. 402 * @param pool Pool used to allocate buffers for incoming data. 403 * @param buff_size The size of each buffer, in bytes. 404 * @param readbuf Array of packet buffers, each has buff_size size. 405 * @param flags Flags to be given to pj_ioqueue_recvfrom(). 406 * 407 * @return PJ_SUCCESS if the operation has been successful, 408 * or the appropriate error code on failure. 409 */ 410 PJ_DECL(pj_status_t) pj_activesock_start_recvfrom2(pj_activesock_t *asock, 411 pj_pool_t *pool, 412 unsigned buff_size, 413 void *readbuf[], 414 pj_uint32_t flags); 375 415 376 416 /** -
pjproject/trunk/pjlib/src/pj/activesock.c
r2185 r2187 18 18 */ 19 19 #include <pj/activesock.h> 20 #include <pj/compat/socket.h> 20 21 #include <pj/assert.h> 21 22 #include <pj/errno.h> … … 242 243 pj_uint32_t flags) 243 244 { 245 void **readbuf; 246 unsigned i; 247 248 PJ_ASSERT_RETURN(asock && pool && buff_size, PJ_EINVAL); 249 250 readbuf = (void**) pj_pool_calloc(pool, asock->async_count, 251 sizeof(void*)); 252 253 for (i=0; i<asock->async_count; ++i) { 254 readbuf[i] = pj_pool_alloc(pool, buff_size); 255 } 256 257 return pj_activesock_start_read2(asock, pool, buff_size, readbuf, flags); 258 } 259 260 261 PJ_DEF(pj_status_t) pj_activesock_start_read2( pj_activesock_t *asock, 262 pj_pool_t *pool, 263 unsigned buff_size, 264 void *readbuf[], 265 pj_uint32_t flags) 266 { 244 267 unsigned i; 245 268 pj_status_t status; … … 259 282 pj_ssize_t size_to_read; 260 283 261 r->pkt = (pj_uint8_t*) pj_pool_alloc(pool, buff_size);284 r->pkt = (pj_uint8_t*)readbuf[i]; 262 285 r->max_size = size_to_read = buff_size; 263 286 … … 278 301 unsigned buff_size, 279 302 pj_uint32_t flags) 303 { 304 void **readbuf; 305 unsigned i; 306 307 PJ_ASSERT_RETURN(asock && pool && buff_size, PJ_EINVAL); 308 309 readbuf = (void**) pj_pool_calloc(pool, asock->async_count, 310 sizeof(void*)); 311 312 for (i=0; i<asock->async_count; ++i) { 313 readbuf[i] = pj_pool_alloc(pool, buff_size); 314 } 315 316 return pj_activesock_start_recvfrom2(asock, pool, buff_size, 317 readbuf, flags); 318 } 319 320 321 PJ_DEF(pj_status_t) pj_activesock_start_recvfrom2( pj_activesock_t *asock, 322 pj_pool_t *pool, 323 unsigned buff_size, 324 void *readbuf[], 325 pj_uint32_t flags) 280 326 { 281 327 unsigned i; … … 295 341 pj_ssize_t size_to_read; 296 342 297 r->pkt = (pj_uint8_t*) pj_pool_alloc(pool, buff_size);343 r->pkt = (pj_uint8_t*) readbuf[i]; 298 344 r->max_size = size_to_read = buff_size; 299 345 r->src_addr_len = sizeof(r->src_addr); … … 372 418 } 373 419 374 } else if (bytes_read <= 0) { 375 420 } else if (bytes_read <= 0 && 421 -bytes_read != PJ_STATUS_FROM_OS(OSERR_EWOULDBLOCK) && 422 -bytes_read != PJ_STATUS_FROM_OS(OSERR_EINPROGRESS) && 423 -bytes_read != PJ_STATUS_FROM_OS(OSERR_ECONNRESET)) 424 { 376 425 pj_size_t remainder; 377 426 pj_bool_t ret;
Note: See TracChangeset
for help on using the changeset viewer.