Changeset 860 for vendor/current/lib/tsocket
- Timestamp:
- May 12, 2014, 8:58:38 PM (11 years ago)
- Location:
- vendor/current/lib/tsocket
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
vendor/current/lib/tsocket/tsocket.h
r740 r860 627 627 char *tsocket_address_unix_path(const struct tsocket_address *addr, 628 628 TALLOC_CTX *mem_ctx); 629 630 /** 631 * @brief Request a syscall optimization for tdgram_recvfrom_send() 632 * 633 * This function is only used to reduce the amount of syscalls and 634 * optimize performance. You should only use this if you know 635 * what you're doing. 636 * 637 * The optimization is off by default. 638 * 639 * @param[in] dgram The tdgram_context of a bsd socket, if this 640 * not a bsd socket the function does nothing. 641 * 642 * @param[in] on The boolean value to turn the optimization on and off. 643 * 644 * @return The old boolean value. 645 * 646 * @see tdgram_recvfrom_send() 647 */ 648 bool tdgram_bsd_optimize_recvfrom(struct tdgram_context *dgram, 649 bool on); 629 650 630 651 #ifdef DOXYGEN … … 688 709 _tdgram_unix_socket(local, remote, mem_ctx, dgram, __location__) 689 710 #endif 711 712 /** 713 * @brief Request a syscall optimization for tstream_readv_send() 714 * 715 * This function is only used to reduce the amount of syscalls and 716 * optimize performance. You should only use this if you know 717 * what you're doing. 718 * 719 * The optimization is off by default. 720 * 721 * @param[in] stream The tstream_context of a bsd socket, if this 722 * not a bsd socket the function does nothing. 723 * 724 * @param[in] on The boolean value to turn the optimization on and off. 725 * 726 * @return The old boolean value. 727 * 728 * @see tstream_readv_send() 729 */ 730 bool tstream_bsd_optimize_readv(struct tstream_context *stream, 731 bool on); 690 732 691 733 /** -
vendor/current/lib/tsocket/tsocket_bsd.c
r740 r860 655 655 void *event_ptr; 656 656 struct tevent_fd *fde; 657 bool optimize_recvfrom; 657 658 658 659 void *readable_private; … … 661 662 void (*writeable_handler)(void *private_data); 662 663 }; 664 665 bool tdgram_bsd_optimize_recvfrom(struct tdgram_context *dgram, 666 bool on) 667 { 668 struct tdgram_bsd *bsds = 669 talloc_get_type(_tdgram_context_data(dgram), 670 struct tdgram_bsd); 671 bool old; 672 673 if (bsds == NULL) { 674 /* not a bsd socket */ 675 return false; 676 } 677 678 old = bsds->optimize_recvfrom; 679 bsds->optimize_recvfrom = on; 680 681 return old; 682 } 663 683 664 684 static void tdgram_bsd_fde_handler(struct tevent_context *ev, … … 838 858 } 839 859 860 840 861 /* 841 862 * this is a fast path, not waiting for the … … 843 864 * about 10%-20% performance in benchmark tests. 844 865 */ 845 tdgram_bsd_recvfrom_handler(req); 846 if (!tevent_req_is_in_progress(req)) { 847 goto post; 866 if (bsds->optimize_recvfrom) { 867 /* 868 * We only do the optimization on 869 * recvfrom if the caller asked for it. 870 * 871 * This is needed because in most cases 872 * we preferr to flush send buffers before 873 * receiving incoming requests. 874 */ 875 tdgram_bsd_recvfrom_handler(req); 876 if (!tevent_req_is_in_progress(req)) { 877 goto post; 878 } 848 879 } 849 880 … … 1401 1432 void *event_ptr; 1402 1433 struct tevent_fd *fde; 1434 bool optimize_readv; 1403 1435 1404 1436 void *readable_private; … … 1407 1439 void (*writeable_handler)(void *private_data); 1408 1440 }; 1441 1442 bool tstream_bsd_optimize_readv(struct tstream_context *stream, 1443 bool on) 1444 { 1445 struct tstream_bsd *bsds = 1446 talloc_get_type(_tstream_context_data(stream), 1447 struct tstream_bsd); 1448 bool old; 1449 1450 if (bsds == NULL) { 1451 /* not a bsd socket */ 1452 return false; 1453 } 1454 1455 old = bsds->optimize_readv; 1456 bsds->optimize_readv = on; 1457 1458 return old; 1459 } 1409 1460 1410 1461 static void tstream_bsd_fde_handler(struct tevent_context *ev, … … 1620 1671 * about 10%-20% performance in benchmark tests. 1621 1672 */ 1622 tstream_bsd_readv_handler(req); 1623 if (!tevent_req_is_in_progress(req)) { 1624 goto post; 1673 if (bsds->optimize_readv) { 1674 /* 1675 * We only do the optimization on 1676 * readv if the caller asked for it. 1677 * 1678 * This is needed because in most cases 1679 * we preferr to flush send buffers before 1680 * receiving incoming requests. 1681 */ 1682 tstream_bsd_readv_handler(req); 1683 if (!tevent_req_is_in_progress(req)) { 1684 goto post; 1685 } 1625 1686 } 1626 1687 -
vendor/current/lib/tsocket/tsocket_helpers.c
r478 r860 213 213 size_t i; 214 214 struct tevent_req *subreq; 215 bool optimize = false; 216 bool save_optimize = false; 217 218 if (state->count > 0) { 219 /* 220 * This is not the first time we asked for a vector, 221 * which means parts of the pdu already arrived. 222 * 223 * In this case it make sense to enable 224 * a syscall/performance optimization if the 225 * low level tstream implementation supports it. 226 */ 227 optimize = true; 228 } 215 229 216 230 TALLOC_FREE(state->vector); … … 256 270 } 257 271 272 if (optimize) { 273 /* 274 * If the low level stream is a bsd socket 275 * we will get syscall optimization. 276 * 277 * If it is not a bsd socket 278 * tstream_bsd_optimize_readv() just returns. 279 */ 280 save_optimize = tstream_bsd_optimize_readv(state->caller.stream, 281 true); 282 } 258 283 subreq = tstream_readv_send(state, 259 284 state->caller.ev, … … 261 286 state->vector, 262 287 state->count); 288 if (optimize) { 289 tstream_bsd_optimize_readv(state->caller.stream, 290 save_optimize); 291 } 263 292 if (tevent_req_nomem(subreq, req)) { 264 293 return;
Note:
See TracChangeset
for help on using the changeset viewer.