In order to make it work for Solaris10 x86 (not opensolaris), I had to
make following minor changes, two issues:
1. using standard C prototype
2. solaris seems to return ETIME instead of EWOULDBLOCK for non-
blocking read
In errno.h:
#define EAGAIN 11 /* Resource temporarily unavailable */
#define EWOULDBLOCK EAGAIN
#define ETIME 62 /* timer expired */
With following changes, it built with GNU Make 3.80, SFW gcc 3.4.3 on
Solaris 10-u7-ga-x86, linked with libevent-1.4.6-stable.
diff -U2 ./solaris_priv.c ../memcached-1.4.0-sol10/./solaris_priv.c
--- ./solaris_priv.c Thu Jul 9 09:43:42 2009
+++ ../memcached-1.4.0-sol10/./solaris_priv.c Wed Jul 15 21:49:01
2009
@@ -3,4 +3,5 @@
#include <stdio.h>
+extern void drop_privileges(void);
/*
* this section of code will drop all (Solaris) privileges including
diff -U2 ./memcached.h ../memcached-1.4.0-sol10/./memcached.h
--- ./memcached.h Thu Jul 9 10:16:24 2009
+++ ../memcached-1.4.0-sol10/./memcached.h Wed Jul 15 21:48:07
2009
@@ -465,5 +465,5 @@
#if HAVE_DROP_PRIVILEGES
-extern void drop_privileges();
+extern void drop_privileges(void);
#else
#define drop_privileges()
diff -U2 ./memcached.c ../memcached-1.4.0-sol10/./memcached.c
--- ./memcached.c Thu Jul 9 10:16:24 2009
+++ ../memcached-1.4.0-sol10/./memcached.c Wed Jul 15 22:14:20
2009
@@ -3016,5 +3016,5 @@
}
if (res == -1) {
- if (errno == EAGAIN || errno == EWOULDBLOCK) {
+ if (errno == EAGAIN || errno == EWOULDBLOCK || errno ==
ETIME) {
break;
}
@@ -3115,5 +3115,5 @@
return TRANSMIT_INCOMPLETE;
}
- if (res == -1 && (errno == EAGAIN || errno == EWOULDBLOCK)) {
+ if (res == -1 && (errno == EAGAIN || errno == EWOULDBLOCK ||
errno == ETIME)) {
if (!update_event(c, EV_WRITE | EV_PERSIST)) {
if (settings.verbose > 0)
@@ -3267,5 +3267,4 @@
}
}
-
/* now try reading from the socket */
res = read(c->sfd, c->ritem, c->rlbytes);
@@ -3285,5 +3284,5 @@
break;
}
- if (res == -1 && (errno == EAGAIN || errno ==
EWOULDBLOCK)) {
+ if (res == -1 && (errno == EAGAIN || errno == EWOULDBLOCK
|| errno == ETIME)) {
if (!update_event(c, EV_READ | EV_PERSIST)) {
if (settings.verbose > 0)
@@ -3297,5 +3296,5 @@
/* otherwise we have a real error, on which we close the
connection */
if (settings.verbose > 0)
- fprintf(stderr, "Failed to read, and not due to
blocking\n");
+ fprintf(stderr, "Failed to read, and not due to
blocking %d\n", errno);
conn_set_state(c, conn_closing);
break;
@@ -3330,5 +3329,5 @@
break;
}
- if (res == -1 && (errno == EAGAIN || errno ==
EWOULDBLOCK)) {
+ if (res == -1 && (errno == EAGAIN || errno == EWOULDBLOCK
|| errno == ETIME)) {
if (!update_event(c, EV_READ | EV_PERSIST)) {
if (settings.verbose > 0)