[427] in Pthreads mailing list archive
Questions about fd_kern.c
daemon@ATHENA.MIT.EDU (Larry V. Streepy, Jr.)
Fri Sep 27 16:10:31 1996
Date: Fri, 27 Sep 1996 13:48:08 -0600
From: "Larry V. Streepy, Jr." <streepy@healthcare.com>
To: pthreads@MIT.EDU
This is a multi-part message in MIME format.
--------------52206BC47BFB4AC81A1C4273
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
All,
I've been running into several problems in the error handling/returning
withing fd_kern.c in the network routines.
There are places where the -errno value is returned instead of -1. Was
this intentional, because it certainly makes the routines non-conformant
with the libc routines.
Assuming that these are oversights, I've attached the diffs to fix the
problems that I've found.
--
Larry V. Streepy, Jr.
Chief Technical Officer, Healthcare Communications, Inc.
mailto:streepy@healthcare.com
(214) 851-7033 (Dallas Main #)
(970) 626-5028 (My office #) (970) 626-4425 (Fax)
--------------52206BC47BFB4AC81A1C4273
Content-Type: text/plain; charset=us-ascii; name="diff.out"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline; filename="diff.out"
*** ../../pthreads-1_60_beta5.old/pthreads/fd_kern.c Sun Feb 11 17:58:30 1996
--- ./fd_kern.c Fri Sep 27 13:47:05 1996
***************
*** 128,134 ****
if ((count = machdep_sys_select(dtablesize, &fd_set_read,
! &fd_set_write, NULL, &__fd_kern_poll_timeout)) < OK) {
if (count == -EINTR) {
return;
}
--- 128,134 ----
if ((count = machdep_sys_select(dtablesize, &fd_set_read,
! &fd_set_write, &fd_set_except, &__fd_kern_poll_timeout)) < OK) {
if (count == -EINTR) {
return;
}
***************
*** 266,272 ****
*/
while ((count = machdep_sys_select(dtablesize, &fd_set_read,
! &fd_set_write, NULL, &__fd_kern_wait_timeout)) < OK) {
if (count == -EINTR) {
return;
}
--- 266,272 ----
*/
while ((count = machdep_sys_select(dtablesize, &fd_set_read,
! &fd_set_write, &fd_set_except, &__fd_kern_wait_timeout)) < OK) {
if (count == -EINTR) {
return;
}
***************
*** 388,394 ****
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = -ETIMEDOUT;
break;
}
pthread_sched_resume();
--- 388,394 ----
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = NOTOK;
break;
}
pthread_sched_resume();
***************
*** 438,444 ****
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = -ETIMEDOUT;
break;
}
pthread_sched_resume();
--- 438,444 ----
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = NOTOK;
break;
}
pthread_sched_resume();
***************
*** 488,494 ****
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = -ETIMEDOUT;
break;
}
pthread_sched_resume();
--- 488,494 ----
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = NOTOK;
break;
}
pthread_sched_resume();
***************
*** 538,544 ****
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = -ETIMEDOUT;
break;
}
pthread_sched_resume();
--- 538,544 ----
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = NOTOK;
break;
}
pthread_sched_resume();
***************
*** 1079,1090 ****
int bind(int fd, const struct sockaddr *name, int namelen)
{
/* Not much to do in bind */
- semaphore *plock;
int ret;
if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
if ((ret = machdep_sys_bind(fd_table[fd]->fd.i, name, namelen)) < OK) {
SET_ERRNO(-ret);
}
fd_unlock(fd, FD_RDWR);
}
--- 1079,1090 ----
int bind(int fd, const struct sockaddr *name, int namelen)
{
/* Not much to do in bind */
int ret;
if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
if ((ret = machdep_sys_bind(fd_table[fd]->fd.i, name, namelen)) < OK) {
SET_ERRNO(-ret);
+ ret = NOTOK;
}
fd_unlock(fd, FD_RDWR);
}
***************
*** 1121,1131 ****
tmpnamelen = sizeof(tmpname);
/* OK now lets see if it really worked */
if (((ret = machdep_sys_getpeername(fd_table[fd]->fd.i,
! &tmpname, &tmpnamelen)) < OK) && (ret == -ENOTCONN)) {
/* Get the error, this function should not fail */
machdep_sys_getsockopt(fd_table[fd]->fd.i, SOL_SOCKET,
! SO_ERROR, &pthread_run->error, &tmpnamelen);
}
} else {
SET_ERRNO(-ret);
--- 1121,1134 ----
tmpnamelen = sizeof(tmpname);
/* OK now lets see if it really worked */
if (((ret = machdep_sys_getpeername(fd_table[fd]->fd.i,
! &tmpname, &tmpnamelen)) < OK)
! && (ret == -ENOTCONN)) {
/* Get the error, this function should not fail */
machdep_sys_getsockopt(fd_table[fd]->fd.i, SOL_SOCKET,
! SO_ERROR, &ret, &tmpnamelen);
! SET_ERRNO(-ret);
! ret = NOTOK;
}
} else {
SET_ERRNO(-ret);
***************
*** 1164,1170 ****
} else {
fd_unlock(fd, FD_RDWR);
SET_ERRNO(-fd_kern);
! return(fd_kern);
}
}
fd_unlock(fd, FD_RDWR);
--- 1167,1173 ----
} else {
fd_unlock(fd, FD_RDWR);
SET_ERRNO(-fd_kern);
! return(NOTOK);
}
}
fd_unlock(fd, FD_RDWR);
***************
*** 1198,1204 ****
int ret;
if ((ret = fd_lock(fd, FD_RDWR, NULL)) == OK) {
- ret = machdep_sys_listen(fd_table[fd]->fd.i, backlog);
if ((ret = machdep_sys_listen(fd_table[fd]->fd.i, backlog)) < OK) {
SET_ERRNO(-ret);
ret = NOTOK;
--- 1201,1206 ----
***************
*** 1246,1252 ****
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = -ETIMEDOUT;
break;
}
pthread_sched_resume();
--- 1248,1254 ----
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = NOTOK;
break;
}
pthread_sched_resume();
***************
*** 1311,1317 ****
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = -ETIMEDOUT;
break;
}
pthread_sched_resume();
--- 1313,1319 ----
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = NOTOK;
break;
}
pthread_sched_resume();
***************
*** 1405,1411 ****
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = -ETIMEDOUT;
break;
}
pthread_sched_resume();
--- 1407,1413 ----
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = NOTOK;
break;
}
pthread_sched_resume();
***************
*** 1471,1477 ****
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = -ETIMEDOUT;
break;
}
pthread_sched_resume();
--- 1473,1479 ----
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = NOTOK;
break;
}
pthread_sched_resume();
***************
*** 1536,1542 ****
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = -ETIMEDOUT;
break;
}
pthread_sched_resume();
--- 1538,1544 ----
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = NOTOK;
break;
}
pthread_sched_resume();
***************
*** 1603,1609 ****
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = -ETIMEDOUT;
break;
}
pthread_sched_resume();
--- 1605,1611 ----
CLEAR_PF_DONE_EVENT(pthread_run);
pthread_sched_resume();
SET_ERRNO(ETIMEDOUT);
! ret = NOTOK;
break;
}
pthread_sched_resume();
--------------52206BC47BFB4AC81A1C4273--