From ea1b02db6ab4864befde88ed03099f075cf7db76 Mon Sep 17 00:00:00 2001 From: Andy Polyakov Date: Tue, 17 May 2005 00:08:28 +0000 Subject: OPENSSL_Applink update. --- crypto/bio/bss_fd.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) (limited to 'crypto/bio/bss_fd.c') diff --git a/crypto/bio/bss_fd.c b/crypto/bio/bss_fd.c index 5e3e187de6..4c229bf641 100644 --- a/crypto/bio/bss_fd.c +++ b/crypto/bio/bss_fd.c @@ -60,7 +60,19 @@ #include #define USE_SOCKETS #include "cryptlib.h" -#include +/* + * As for unconditional usage of "UPLINK" interface in this module. + * Trouble is that unlike Unix file descriptors [which are indexes + * in kernel-side per-process table], corresponding descriptors on + * platforms which require "UPLINK" interface seem to be indexes + * in a user-land, non-global table. Well, in fact they are indexes + * in stdio _iob[], and recall that _iob[] was the very reason why + * "UPLINK" interface was introduced in first place. But one way on + * another. Neither libcrypto or libssl use this BIO meaning that + * file descriptors can only be provided by application. Therefore + * "UPLINK" calls are due... + */ +#include "bio_lcl.h" static int fd_write(BIO *h, const char *buf, int num); static int fd_read(BIO *h, char *buf, int size); @@ -100,9 +112,9 @@ BIO *BIO_new_fd(int fd,int close_flag) static int fd_new(BIO *bi) { bi->init=0; - bi->num=0; + bi->num=-1; bi->ptr=NULL; - bi->flags=0; + bi->flags=BIO_FLAGS_UPLINK; /* essentially redundant */ return(1); } @@ -113,10 +125,10 @@ static int fd_free(BIO *a) { if (a->init) { - close(a->num); + UP_close(a->num); } a->init=0; - a->flags=0; + a->flags=BIO_FLAGS_UPLINK; } return(1); } @@ -128,7 +140,7 @@ static int fd_read(BIO *b, char *out,int outl) if (out != NULL) { clear_sys_error(); - ret=read(b->num,out,outl); + ret=UP_read(b->num,out,outl); BIO_clear_retry_flags(b); if (ret <= 0) { @@ -143,7 +155,7 @@ static int fd_write(BIO *b, const char *in, int inl) { int ret; clear_sys_error(); - ret=write(b->num,in,inl); + ret=UP_write(b->num,in,inl); BIO_clear_retry_flags(b); if (ret <= 0) { @@ -163,11 +175,11 @@ static long fd_ctrl(BIO *b, int cmd, long num, void *ptr) case BIO_CTRL_RESET: num=0; case BIO_C_FILE_SEEK: - ret=(long)lseek(b->num,num,0); + ret=(long)UP_lseek(b->num,num,0); break; case BIO_C_FILE_TELL: case BIO_CTRL_INFO: - ret=(long)lseek(b->num,0,1); + ret=(long)UP_lseek(b->num,0,1); break; case BIO_C_SET_FD: fd_free(b); -- cgit v1.2.3