Date: Tue, 14 Nov 2006 16:04:28 GMT From: Michael Bushkov <bushman@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 109932 for review Message-ID: <200611141604.kAEG4SAF072031@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=109932 Change 109932 by bushman@bushman_nss_ldap_cached on 2006/11/14 16:04:16 Using #defines instead of hard coded constants for use_alternate_io-stuff (large buffers processing). Affected files ... .. //depot/projects/soc2006/nss_ldap_cached/src/usr.sbin/cached/cached.c#10 edit .. //depot/projects/soc2006/nss_ldap_cached/src/usr.sbin/cached/query.c#8 edit .. //depot/projects/soc2006/nss_ldap_cached/src/usr.sbin/cached/query.h#4 edit Differences ... ==== //depot/projects/soc2006/nss_ldap_cached/src/usr.sbin/cached/cached.c#10 (text) ==== @@ -424,18 +424,20 @@ * The code below implements buffer splitting/mergind for send/receive * operations. It also does the actual socket IO operations. */ - if (((qstate->use_alternate_io == 0) && + if (((qstate->use_alternate_io == DONT_USE_ALTERNATE_IO) && (qstate->kevent_watermark <= event_data->data)) || - ((qstate->use_alternate_io != 0) && + ((qstate->use_alternate_io != DONT_USE_ALTERNATE_IO) && (qstate->io_buffer_watermark <= event_data->data))) { - if (qstate->use_alternate_io == 1) { + if (qstate->use_alternate_io == + USE_ALTERNATE_IO_WITH_SOCK_RW) { switch (qstate->io_buffer_filter) { case EVFILT_READ: io_res = query_socket_read(qstate, qstate->io_buffer_p, qstate->io_buffer_watermark); if (io_res < 0) { - qstate->use_alternate_io = 0; + qstate->use_alternate_io = + DONT_USE_ALTERNATE_IO; qstate->process_func = NULL; } else { qstate->io_buffer_p += io_res; @@ -444,7 +446,8 @@ qstate->io_buffer_size) { qstate->io_buffer_p = qstate->io_buffer; - qstate->use_alternate_io = 0; + qstate->use_alternate_io = + DONT_USE_ALTERNATE_IO; } } break; @@ -453,7 +456,9 @@ } } - if ((qstate->use_alternate_io == 0) || (qstate->use_alternate_io == 2)) { + if ((qstate->use_alternate_io == DONT_USE_ALTERNATE_IO) || + (qstate->use_alternate_io == + USE_ALTERNATE_IO_WITHOUT_SOCK_RW)) { do res = qstate->process_func(qstate); while ((qstate->kevent_watermark == 0) && @@ -464,12 +469,14 @@ qstate->process_func = NULL; } - if ((qstate->use_alternate_io == 1) && - (qstate->io_buffer_filter == EVFILT_WRITE)) { + if ((qstate->use_alternate_io == + USE_ALTERNATE_IO_WITH_SOCK_RW) && + (qstate->io_buffer_filter == EVFILT_WRITE)) { io_res = query_socket_write(qstate, qstate->io_buffer_p, qstate->io_buffer_watermark); if (io_res < 0) { - qstate->use_alternate_io = 0; + qstate->use_alternate_io = + DONT_USE_ALTERNATE_IO; qstate->process_func = NULL; } else qstate->io_buffer_p += io_res; @@ -477,11 +484,12 @@ } else { /* assuming that socket was closed */ qstate->process_func = NULL; - qstate->use_alternate_io = 0; + qstate->use_alternate_io = DONT_USE_ALTERNATE_IO; } if (((qstate->process_func == NULL) && - ((qstate->use_alternate_io == 0) || (qstate->use_alternate_io == 2))) || + ((qstate->use_alternate_io == DONT_USE_ALTERNATE_IO) || + (qstate->use_alternate_io == USE_ALTERNATE_IO_WITHOUT_SOCK_RW))) || (eof_res != 0) || (res != 0)) { destroy_query_state(qstate); close(event_data->ident); @@ -499,11 +507,12 @@ query_timeout.tv_sec = qstate->timeout.tv_sec - query_timeout.tv_sec; - if ((qstate->use_alternate_io == 1) && (qstate->io_buffer_p == - qstate->io_buffer + qstate->io_buffer_size)) - qstate->use_alternate_io = 0; + if ((qstate->use_alternate_io == USE_ALTERNATE_IO_WITH_SOCK_RW) + && (qstate->io_buffer_p == + qstate->io_buffer + qstate->io_buffer_size)) + qstate->use_alternate_io = DONT_USE_ALTERNATE_IO; - if (qstate->use_alternate_io == 0) { + if (qstate->use_alternate_io == DONT_USE_ALTERNATE_IO) { /* * If we must send/receive the large block of data, * we should prepare the query_state's io_XXX fields. @@ -533,9 +542,11 @@ qstate->read_func = query_io_buffer_read; if (qstate->kevent_filter == EVFILT_READ) - qstate->use_alternate_io = 1; + qstate->use_alternate_io = + USE_ALTERNATE_IO_WITH_SOCK_RW; else - qstate->use_alternate_io = 2; + qstate->use_alternate_io = + USE_ALTERNATE_IO_WITHOUT_SOCK_RW; qstate->io_buffer_watermark = MAX_SOCKET_IO_SIZE; EV_SET(&eventlist[1], event_data->ident, ==== //depot/projects/soc2006/nss_ldap_cached/src/usr.sbin/cached/query.c#8 (text) ==== @@ -1226,7 +1226,7 @@ qstate->io_buffer_p += result; if (qstate->io_buffer_p == qstate->io_buffer + qstate->io_buffer_size) { - qstate->use_alternate_io = 1; + qstate->use_alternate_io = USE_ALTERNATE_IO_WITH_SOCK_RW; qstate->io_buffer_p = qstate->io_buffer; qstate->write_func = query_socket_write; ==== //depot/projects/soc2006/nss_ldap_cached/src/usr.sbin/cached/query.h#4 (text) ==== @@ -36,6 +36,10 @@ #include "config.h" #include "protocol.h" +#define DONT_USE_ALTERNATE_IO (0) +#define USE_ALTERNATE_IO_WITH_SOCK_RW (1) +#define USE_ALTERNATE_IO_WITHOUT_SOCK_RW (1 << 1) + struct query_state; struct configuration; struct configuration_entry;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200611141604.kAEG4SAF072031>