summaryrefslogtreecommitdiffstats
path: root/src/plugin.c
diff options
context:
space:
mode:
authorNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-06-02 14:22:47 -0400
committerNalin Dahyabhai <nalin.dahyabhai@pobox.com>2008-06-02 14:22:47 -0400
commitec7f4cfda2c2708ed7ec3522600c95bd32fc43ea (patch)
tree1b3cf1471d0feacee35bfbe2bae72b2ead3dba36 /src/plugin.c
parentc9ad0149295a99d832c39e5d8ef43294d06e39ee (diff)
downloadslapi-nis-ec7f4cfda2c2708ed7ec3522600c95bd32fc43ea.tar.gz
slapi-nis-ec7f4cfda2c2708ed7ec3522600c95bd32fc43ea.tar.xz
slapi-nis-ec7f4cfda2c2708ed7ec3522600c95bd32fc43ea.zip
- initial support for returning larger entries over tcp than we can over udp
- make the tcp sizes tunable
Diffstat (limited to 'src/plugin.c')
-rw-r--r--src/plugin.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 1b54d81..c35d0d7 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -28,6 +28,7 @@
#include <arpa/inet.h>
#include <assert.h>
#include <errno.h>
+#include <fcntl.h>
#include <netinet/in.h>
#include <poll.h>
#include <stdlib.h>
@@ -155,6 +156,8 @@ plugin_state_init(Slapi_PBlock *pb, struct plugin_state **lstate)
}
state->plugin_base = NULL;
state->plugin_desc = &plugin_description;
+ state->max_value_size = DEFAULT_MAX_VALUE_SIZE;
+ state->max_dgram_size = DEFAULT_MAX_DGRAM_SIZE;
slapi_pblock_get(pb, SLAPI_PLUGIN_IDENTITY, &state->plugin_identity);
slapi_pblock_get(pb, SLAPI_TARGET_DN, &state->plugin_base);
@@ -175,7 +178,7 @@ plugin_state_init(Slapi_PBlock *pb, struct plugin_state **lstate)
* listeners, over both IPv4 and IPv6. */
state->n_listeners = 0;
for (i = 0; i < 2; i++) {
- int pf, type, one, port, ret;
+ int pf, type, one, flags, port, ret;
const char *sock_desc;
/* Before we do anything else, on our second trip through, make
* sure that the first socket was created, because we'll need
@@ -202,7 +205,7 @@ plugin_state_init(Slapi_PBlock *pb, struct plugin_state **lstate)
sock_desc);
continue;
}
- /* Mark the socket as reusable. */
+ /* Mark the socket as reusable and non-blocking. */
one = 1;
if (setsockopt(sockfd, IPPROTO_IP, SO_REUSEADDR,
&one, sizeof(one)) != 0) {
@@ -211,7 +214,11 @@ plugin_state_init(Slapi_PBlock *pb, struct plugin_state **lstate)
"error marking %s socket for reuse, "
"continuing\n", sock_desc);
}
- /* Bind to a reserved port. */
+ flags = fcntl(sockfd, F_GETFL);
+ if ((flags & O_NONBLOCK) == 0) {
+ fcntl(sockfd, F_SETFL, flags | O_NONBLOCK);
+ }
+ /* Bind to a reserved port, don't really care which one. */
memset(&sin, 0, sizeof(sin));
memset(&sin6, 0, sizeof(sin6));
sin.sin_family = AF_INET;