cvs commit: apache-apr/include apr_errno.h apr_lock.h apr_network_io.h apr_thread_proc.h apr_time.h
rbb 99/06/22 09:57:42 Modified:apr/locks/unix locks.c apr/network_io/unix poll.c sockets.c apr/threadproc/unix procsup.c thread.c threadpriv.c apr/time/unix access.c include apr_errno.h apr_lock.h apr_network_io.h apr_thread_proc.h apr_time.h Log: The rest of the functions needed to allow APR users to access the data field of each APR type. Revision ChangesPath 1.10 +35 -0 apache-apr/apr/locks/unix/locks.c Index: locks.c === RCS file: /home/cvs/apache-apr/apr/locks/unix/locks.c,v retrieving revision 1.9 retrieving revision 1.10 diff -u -r1.9 -r1.10 --- locks.c 1999/06/22 14:56:29 1.9 +++ locks.c 1999/06/22 16:57:29 1.10 @@ -142,3 +142,38 @@ return APR_SUCCESS; } +/* ***APRDOC + * ap_status_t ap_get_lockdata(ap_lock_t *, void *) + *Return the context associated with the current lock. + * arg 1) The currently open lock. + * arg 2) The user data associated with the lock. + */ +ap_status_t ap_get_lockdata(struct lock_t *lock, void *data) +{ +if (lock != NULL) { +return ap_get_userdata(lock-cntxt, data); +} +else { +data = NULL; +return APR_ENOLOCK; +} +} + +/* ***APRDOC + * ap_status_t ap_set_lockdata(ap_lock_t *, void *) + *Return the context associated with the current lock. + * arg 1) The currently open lock. + * arg 2) The user data to associate with the lock. + */ +ap_status_t ap_set_lockdata(struct lock_t *lock, void *data) +{ +if (lock != NULL) { +return ap_set_userdata(lock-cntxt, data); +} +else { +data = NULL; +return APR_ENOLOCK; +} +} + + 1.14 +36 -0 apache-apr/apr/network_io/unix/poll.c Index: poll.c === RCS file: /home/cvs/apache-apr/apr/network_io/unix/poll.c,v retrieving revision 1.13 retrieving revision 1.14 diff -u -r1.13 -r1.14 --- poll.c1999/06/16 11:15:59 1.13 +++ poll.c1999/06/22 16:57:30 1.14 @@ -291,3 +291,39 @@ } #endif + +/* ***APRDOC + * ap_status_t ap_get_polldata(ap_pollfd_t *, void *) + *Return the context associated with the current poll. + * arg 1) The currently open pollfd. + * arg 2) The user data associated with the pollfd. + */ +ap_status_t ap_get_polldata(struct pollfd_t *pollfd, void *data) +{ +if (pollfd != NULL) { +return ap_get_userdata(pollfd-cntxt, data); +} +else { +data = NULL; +return APR_ENOFILE; +} +} + +/* ***APRDOC + * ap_status_t ap_set_polldata(ap_pollfd_t *, void *) + *Return the context associated with the current poll. + * arg 1) The currently open pollfd. + * arg 2) The user data to associate with the pollfd. + */ +ap_status_t ap_set_polldata(struct pollfd_t *pollfd, void *data) +{ +if (pollfd != NULL) { +return ap_set_userdata(pollfd-cntxt, data); +} +else { +data = NULL; +return APR_ENOFILE; +} +} + + 1.20 +35 -0 apache-apr/apr/network_io/unix/sockets.c Index: sockets.c === RCS file: /home/cvs/apache-apr/apr/network_io/unix/sockets.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -r1.19 -r1.20 --- sockets.c 1999/06/02 18:44:53 1.19 +++ sockets.c 1999/06/22 16:57:31 1.20 @@ -207,3 +207,38 @@ } } +/* ***APRDOC + * ap_status_t ap_get_socketdata(ap_socket_t *, void *) + *Return the context associated with the current socket. + * arg 1) The currently open socket. + * arg 2) The user data associated with the socket. + */ +ap_status_t ap_get_socketdata(struct socket_t *socket, void *data) +{ +if (socket != NULL) { +return ap_get_userdata(socket-cntxt, data); +} +else { +data = NULL; +return APR_ENOSOCKET; +} +} + +/* ***APRDOC + * ap_status_t ap_set_socketdata(ap_socket_t *, void *) + *Return the context associated with the current socket. + * arg 1) The currently open socket. + * arg 2) The user data to associate with the socket. + */ +ap_status_t ap_set_socketdata(struct socket_t *socket, void *data) +{ +if (socket != NULL) { +return ap_set_userdata(socket-cntxt, data); +} +else { +
cvs commit: apache-apr/include apr_errno.h apr_lock.h
rbb 99/05/24 11:16:52 Modified:apr/locks/unix crossproc.c intraproc.c locks.c apr/test testthread.c include apr_errno.h apr_lock.h Log: Locking functions now all return status codes. Also updated test function appropriately. Revision ChangesPath 1.6 +47 -37apache-apr/apr/locks/unix/crossproc.c Index: crossproc.c === RCS file: /home/cvs/apache-apr/apr/locks/unix/crossproc.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -r1.5 -r1.6 --- crossproc.c 1999/05/24 02:04:03 1.5 +++ crossproc.c 1999/05/24 18:16:34 1.6 @@ -79,12 +79,12 @@ if (new-interproc 0) { lock_cleanup(new); -return APR_FAILURE; +return errno; } ick.val = 1; -if (senctl(new-interproc, 0, SETVAL, ick) 0) { +if (semctl(new-interproc, 0, SETVAL, ick) 0) { lock_cleanup(new); -return APR_FAILURE; +return errno; } /* pre-initialize these */ new-op_on.sem_num = 0; @@ -103,7 +103,7 @@ { new-curr_locked == 1; if (semop(lock-interproc, lock-op_on, 1) 0) { -return(APR_FAILURE); +return errno; } return APR_SUCCESS; } @@ -111,7 +111,7 @@ ap_status_t unlock_inter(struct lock_t *lock) { if (semop(lock-interproc, lock-op_off, 1) 0) { -return(APR_FAILURE); +return errno; } new-curr_locked == 0; return APR_SUCCESS; @@ -119,11 +119,13 @@ ap_status_t destroy_inter_lock(struct lock_t *lock) { -if (lock_cleanup(lock) == APR_SUCCESS) { +ap_status_t stat; + +if ((stat = lock_cleanup(lock)) == APR_SUCCESS) { ap_kill_cleanup(lock-cntxt-pool, lock, lock_cleanup); return APR_SUCCESS; } -return APR_FAILURE; +return stat; } #elif defined (USE_PROC_PTHREAD_SERIALIZE) @@ -131,10 +133,10 @@ { if (lock-curr_locked == 1) { if (pthread_mutex_unlock(lock-interproc)) { -return APR_FAILURE; +return errno; } if (munmap((caddr_t)lock-interproc, sizeof(pthread_mutex_t))){ -return APR_FAILURE; +return errno; } } return APR_SUCCESS; @@ -142,39 +144,40 @@ ap_status_t create_inter_lock(struct lock_t *new) { +ap_status_t stat; int fd; pthread_mutexattr_t mattr; fd = open(/dev/zero, O_RDWR); if (fd 0) { -return APR_FAILURE; +return errno; } new-interproc = (pthread_mutex_t *)mmap((caddr_t) 0, sizeof(pthread_mutex_t), PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); if (new-interproc = (void *) (caddr_t) -1) { -return APR_FAILURE; +return errno; } close(fd); -if ((errno = pthread_mutexattr_init(mattr))) { +if ((stat = pthread_mutexattr_init(mattr))) { lock_cleanup(new); -return APR_FAILURE; +return stat; } -if ((errno = pthread_mutexattr_setpshared(mattr, +if ((stat = pthread_mutexattr_setpshared(mattr, PTHREAD_PROCESS_SHARED))) { lock_cleanup(new); -return APR_FAILURE; +return stat; } -if ((errno = pthread_mutex_init(new-interproc, mattr))) { +if ((stat = pthread_mutex_init(new-interproc, mattr))) { lock_cleanup(new); -return APR_FAILURE; +return stat; } -if ((errno = pthread_mutex_destroy(mattr))) { +if ((stat = pthread_mutex_destroy(mattr))) { lock_cleanup(new); -return APR_FAILURE; +return stat; } new-curr_locked == 0; @@ -184,17 +187,20 @@ ap_status_t lock_inter(struct lock_t *lock) { +ap_status_t stat; new-curr_locked == 1; -if (errno = pthread_mutex_lock(lock-interproc)) { -return(APR_FAILURE); +if (stat = pthread_mutex_lock(lock-interproc)) { +return stat; } return APR_SUCCESS; } ap_status_t unlock_inter(struct lock_t *lock) { -if (errno = pthread_mutex_unlock(lock-interproc)) { -return(APR_FAILURE); +ap_status_t stat; + +if (stat = pthread_mutex_unlock(lock-interproc)) { +returno stat; } new-curr_locked == 0; return APR_SUCCESS; @@ -202,11 +208,12 @@ ap_status_t destroy_inter_lock(struct lock_t *lock) { -if (lock_cleanup(lock) == APR_SUCCESS) { +ap_status_t stat; +if ((stat = lock_cleanup(lock)) == APR_SUCCESS) { ap_kill_cleanup(lock-cntxt-pool, lock, lock_cleanup); return APR_SUCCESS; } -