You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by dr...@hyperreal.org on 1999/10/22 13:25:43 UTC
cvs commit: apache-2.0/src/os/beos beosd.c iol_socket.c
dreid 99/10/22 04:25:42
Modified: src/os/beos beosd.c iol_socket.c
Log:
This brings BeOS back up to date with the recent changes.
Revision Changes Path
1.4 +4 -4 apache-2.0/src/os/beos/beosd.c
Index: beosd.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/os/beos/beosd.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- beosd.c 1999/09/07 22:30:59 1.3
+++ beosd.c 1999/10/22 11:25:41 1.4
@@ -131,7 +131,7 @@
uid_t uid = atoi(&beosd_config.user_name[1]);
if ((ent = getpwuid(uid)) == NULL) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, NULL,
+ ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
"getpwuid: couldn't determine user name from uid %u, "
"you probably need to modify the User directive",
(unsigned)uid);
@@ -144,7 +144,7 @@
name = beosd_config.user_name;
if (setgid(beosd_config.group_id) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, NULL,
+ ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
"setgid: unable to set group id to Group %u",
(unsigned)beosd_config.group_id);
return -1;
@@ -153,7 +153,7 @@
/* Reset `groups' attributes. */
if (initgroups(name, beosd_config.group_id) == -1) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, NULL,
+ ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
"initgroups: unable to set groups for User %s "
"and Group %u", name, (unsigned)beosd_config.group_id);
return -1;
@@ -172,7 +172,7 @@
/* Only try to switch if we're running as root */
if (!geteuid() && (
setuid(beosd_config.user_id) == -1)) {
- ap_log_error(APLOG_MARK, APLOG_ALERT, NULL,
+ ap_log_error(APLOG_MARK, APLOG_ALERT, errno, NULL,
"setuid: unable to change uid");
return -1;
}
1.2 +55 -36 apache-2.0/src/os/beos/iol_socket.c
Index: iol_socket.c
===================================================================
RCS file: /home/cvs/apache-2.0/src/os/beos/iol_socket.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- iol_socket.c 1999/07/12 22:51:14 1.1
+++ iol_socket.c 1999/10/22 11:25:42 1.2
@@ -58,6 +58,7 @@
#include "httpd.h"
#include "ap_iol.h"
+#include "iol_socket.h"
#include <errno.h>
#include <sys/types.h>
@@ -72,7 +73,8 @@
int timeout;
} iol_socket;
-static int beos_setopt(ap_iol *viol, ap_iol_option opt, const void *value)
+static ap_status_t beos_setopt(ap_iol *viol, ap_iol_option opt,
+ const void *value)
{
iol_socket *iol = (iol_socket *)viol;
@@ -81,13 +83,12 @@
iol->timeout = *(const int *)value;
break;
default:
- errno = EINVAL;
- return -1;
+ return APR_EINVAL;
}
- return 0;
+ return APR_SUCCESS;
}
-static int beos_getopt(ap_iol *viol, ap_iol_option opt, void *value)
+static ap_status_t beos_getopt(ap_iol *viol, ap_iol_option opt, void *value)
{
iol_socket *iol = (iol_socket *)viol;
@@ -96,16 +97,20 @@
*(int *)value = iol->timeout;
break;
default:
- errno = EINVAL;
- return -1;
+ return APR_EINVAL;
}
- return 0;
+ return APR_SUCCESS;
}
-static int set_nonblock(int fd)
+static ap_status_t set_nonblock(int fd)
{
int on = 1;
- return setsockopt(fd, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(on));
+ int rv;
+ rv = setsockopt(fd, SOL_SOCKET, SO_NONBLOCK, &on, sizeof(int));
+
+ if (rv == 0)
+ return APR_SUCCESS;
+ return errno;
}
/* the timeout code is a separate routine because it requires
@@ -115,7 +120,7 @@
/* this macro expands into the four basic i/o methods */
#define method(name, args, syscall, selread, selwrite) \
- static int beos_##name##_timeout args \
+ static ap_status_t beos_##name##_timeout args \
{ \
iol_socket *iol = (iol_socket *)viol; \
fd_set fdset; \
@@ -130,27 +135,38 @@
rv = select(iol->fd + 1, selread, selwrite, NULL, iol->timeout < 0 ? NULL : &tv); \
} while (rv == -1 && errno == EINTR); \
if (!FD_ISSET(iol->fd, &fdset)) { \
- errno = ETIMEDOUT; \
- return -1; \
+ return APR_ETIMEDOUT; \
} \
do { \
rv = syscall(iol->fd, arg1, arg2, 0); \
} while (rv == -1 && errno == EINTR); \
- return rv; \
+ if (rv >= 0) { \
+ *nbytes = rv; \
+ return APR_SUCCESS; \
+ } \
+ return errno; \
+ \
} \
\
- static int beos_##name args \
+ static ap_status_t beos_##name args \
{ \
iol_socket *iol = (iol_socket *)viol; \
int rv; \
\
+ /* Present to zero until some bytes are actually written */ \
+ *nbytes = 0; \
if (!(iol->flags & FD_NONBLOCKING_SET)) { \
if (iol->timeout < 0) { \
- return syscall(iol->fd, arg1, arg2, 0); \
+ rv = syscall(iol->fd, arg1, arg2, 0); \
+ if (rv >= 0) { \
+ *nbytes = rv; \
+ return APR_SUCCESS; \
+ } \
+ return errno; \
} \
/* must shift descriptor to blocking mode now */ \
- if (set_nonblock(iol->fd)) { \
- return -1; \
+ if ((rv = set_nonblock(iol->fd)) != APR_SUCCESS) { \
+ return rv; \
} \
iol->flags |= FD_NONBLOCKING_SET; \
} \
@@ -160,19 +176,25 @@
do { \
rv = syscall(iol->fd, arg1, arg2, 0); \
} while (rv == -1 && errno == EINTR); \
- if (rv >= 0) { \
- return rv; \
+ if ((errno == EWOULDBLOCK || errno == EAGAIN) && iol->timeout != 0) { \
+ return beos_##name##_timeout(viol, arg1, arg2, nbytes); \
} \
- if (errno == EWOULDBLOCK && iol->timeout != 0) { \
- return beos_##name##_timeout(viol, arg1, arg2); \
+ if (rv >= 0) { \
+ *nbytes = rv; \
+ return APR_SUCCESS; \
} \
- return -1; \
- } \
+ return errno; \
+ }
+
+method(write, (ap_iol *viol, const char *arg1, ap_size_t arg2, ap_ssize_t *nbytes), send, NULL, &fdset)
+method(read, (ap_iol *viol, char *arg1, ap_size_t arg2, ap_ssize_t *nbytes), recv, &fdset, NULL)
-method(write, (ap_iol *viol, const char *arg1, int arg2), send, NULL, &fdset)
-method(read, (ap_iol *viol, char *arg1, int arg2), recv, &fdset, NULL)
+static ap_status_t beos_writev(ap_iol *viol, const struct iovec *vec, int arg2, ap_ssize_t *nbytes)
+{
+ return beos_write(viol, vec[0].iov_base, vec[0].iov_len, nbytes);
+}
-static int beos_close(ap_iol *viol)
+static ap_status_t beos_close(ap_iol *viol)
{
iol_socket *iol = (iol_socket *)viol;
int rv;
@@ -181,16 +203,13 @@
rv = closesocket(iol->fd);
saved_errno = errno;
free(iol);
- errno = saved_errno;
- return rv;
-}
-
-static int beos_writev(ap_iol *viol, const struct iovec *vec, int nvec)
-{
-return beos_write(viol,vec[0].iov_base,vec[0].iov_len);
+ if (rv == 0) {
+ return APR_SUCCESS;
+ }
+ return saved_errno;
}
-static const ap_iol_methods beos_methods = {
+static const ap_iol_methods socket_methods = {
beos_close,
beos_write,
beos_writev,
@@ -208,7 +227,7 @@
return NULL;
}
iol = malloc(sizeof(iol_socket));
- iol->iol.methods = &beos_methods;
+ iol->iol.methods = &socket_methods;
iol->fd = fd;
iol->timeout = -1;
iol->flags = 0;