More SOCKS versus 64-bit patches from Jens Hamisch.
Jarkko Hietaniemi [Wed, 22 Nov 2000 21:56:02 +0000 (21:56 +0000)]
p4raw-id: //depot/perl@7818

doio.c
embed.h
embed.pl
makedef.pl
perl.h
pp_sys.c
proto.h
t/lib/io_sock.t

diff --git a/doio.c b/doio.c
index bd4d353..3c0bcf1 100644 (file)
--- a/doio.c
+++ b/doio.c
@@ -60,9 +60,6 @@ typedef struct __s64_iobuffer {
     int *buffer;                               /* the buffer */
 } S64_IOB;
 
-static S64_IOB *_s64_get_buffer( PerlIO *f);
-static S64_IOB *_s64_create_buffer( PerlIO *f);
-static int _s64_malloc( S64_IOB *ptr);
 #endif
 
 bool
@@ -2094,6 +2091,12 @@ Perl_do_shmio(pTHX_ I32 optype, SV **mark, SV **sp)
 
 static S64_IOB *s64_buffer = (S64_IOB *) NULL;
 
+/* initialize the buffer area */
+/* required after a fork(2) call in order to remove side effects */
+void Perl_do_s64_init_buffer() {
+    s64_buffer = (S64_IOB *) NULL;
+}
+
 /* get a buffered stream pointer */
 static S64_IOB *S_s64_get_buffer( PerlIO *fp) {
     S64_IOB *ptr = s64_buffer;
@@ -2103,7 +2106,7 @@ static S64_IOB *S_s64_get_buffer( PerlIO *fp) {
 }
 
 /* create a buffered stream pointer */
-static S64_IOB *_s64_create_buffer( PerlIO *f) {
+static S64_IOB *S_s64_create_buffer( PerlIO *f) {
     S64_IOB *ptr = malloc( sizeof( S64_IOB));
     if( ptr) {
        ptr->fp = f;
@@ -2135,7 +2138,7 @@ void Perl_do_s64_delete_buffer( PerlIO *f) {
 
 /* internal buffer management */
 #define _S64_BUFFER_SIZE 32
-static int _s64_malloc( S64_IOB *ptr) {
+static int S_s64_malloc( S64_IOB *ptr) {
     if( ptr) {
        if( !ptr->buffer) {
            ptr->buffer = (int *) calloc( _S64_BUFFER_SIZE, sizeof( int));
diff --git a/embed.h b/embed.h
index b7db7c0..80d6537 100644 (file)
--- a/embed.h
+++ b/embed.h
 #define do_vop                 Perl_do_vop
 #if defined(SOCKS_64BIT_BUG)
 #define s64_get_buffer         S_s64_get_buffer
+#define s64_create_buffer      S_s64_create_buffer
+#define s64_malloc             S_s64_malloc
 #endif
 #define dofile                 Perl_dofile
 #define dowantarray            Perl_dowantarray
 #define do_vop(a,b,c,d)                Perl_do_vop(aTHX_ a,b,c,d)
 #if defined(SOCKS_64BIT_BUG)
 #define s64_get_buffer(a)      S_s64_get_buffer(aTHX_ a)
+#define s64_create_buffer(a)   S_s64_create_buffer(aTHX_ a)
+#define s64_malloc(a)          S_s64_malloc(aTHX_ a)
 #endif
 #define dofile(a)              Perl_dofile(aTHX_ a)
 #define dowantarray()          Perl_dowantarray(aTHX)
 #define Perl_do_vop            CPerlObj::Perl_do_vop
 #define do_vop                 Perl_do_vop
 #if defined(SOCKS_64BIT_BUG)
-#define S_s64_get_buffer       CPerlObj::S_s64_get_buffer
-#define s64_get_buffer         S_s64_get_buffer
 #define do_s64_tell            Perl_do_s64_tell
 #define do_s64_fread           Perl_do_s64_fread
 #define do_s64_getc            Perl_do_s64_getc
 #define do_s64_seek            Perl_do_s64_seek
 #define do_s64_ungetc          Perl_do_s64_ungetc
 #define do_s64_delete_buffer   Perl_do_s64_delete_buffer
+#define do_s64_init_buffer     Perl_do_s64_init_buffer
+#define S_s64_get_buffer       CPerlObj::S_s64_get_buffer
+#define s64_get_buffer         S_s64_get_buffer
+#define S_s64_create_buffer    CPerlObj::S_s64_create_buffer
+#define s64_create_buffer      S_s64_create_buffer
+#define S_s64_malloc           CPerlObj::S_s64_malloc
+#define s64_malloc             S_s64_malloc
 #endif
 #define Perl_dofile            CPerlObj::Perl_dofile
 #define dofile                 Perl_dofile
index 498ab5c..7e06389 100755 (executable)
--- a/embed.pl
+++ b/embed.pl
@@ -1506,13 +1506,16 @@ p       |UV     |do_vecget      |SV* sv|I32 offset|I32 size
 p      |void   |do_vecset      |SV* sv
 p      |void   |do_vop         |I32 optype|SV* sv|SV* left|SV* right
 #if defined(SOCKS_64BIT_BUG)
-s      |S64_IOB*|s64_get_buffer|PerlIO* fp
 Ajnop  |Off_t  |do_s64_tell    |PerlIO* fp
 Ajnop  |SSize_t|do_s64_fread   |void *buf|SSize_t count|PerlIO* fp
 Ajnop  |int    |do_s64_getc    |PerlIO* fp
 Ajnop  |int    |do_s64_seek    |PerlIO* fp|Off_t pos|int whence
 Ajnop  |int    |do_s64_ungetc  |int ch|PerlIO* fp
 Ajnop  |void   |do_s64_delete_buffer|PerlIO* fp
+Ajnop  |void   |do_s64_init_buffer
+s      |S64_IOB *      |s64_get_buffer         |PerlIO *f
+s      |S64_IOB *      |s64_create_buffer      |PerlIO *f
+s      |int            |s64_malloc             |S64_IOB *ptr
 #endif
 p      |OP*    |dofile         |OP* term
 Ap     |I32    |dowantarray
index bf43e66..2cc9a09 100644 (file)
@@ -480,12 +480,13 @@ unless ($define{'FAKE_THREADS'}) {
 # All quad int platforms are assumed to have broken SOCKS
 unless ($define{USE_SOCKS} && $define{USE_64_BIT_ALL}) {
     skip_symbols [qw(
+                    Perl_do_s64_delete_buffer
                     Perl_do_s64_fread
                     Perl_do_s64_getc
-                    Perl_do_s64_delete_buffer
+                    Perl_do_s64_init_buffer
                     Perl_do_s64_seek
                     Perl_do_s64_tell
-                    Perl_do_s64_tell
+                    Perl_do_s64_ungetc
                    )];
 }
 
diff --git a/perl.h b/perl.h
index de6185b..f17f3a9 100644 (file)
--- a/perl.h
+++ b/perl.h
@@ -3443,6 +3443,16 @@ typedef struct am_table_short AMTS;
 #   include <libutil.h>                /* setproctitle() in some FreeBSDs */
 #endif
 
+#ifdef SOCKS_64BIT_BUG
+typedef struct __s64_iobuffer {
+    struct __s64_iobuffer *next, *last;                /* Queue pointer */
+    PerlIO *fp;                                        /* Assigned file pointer */
+    int cnt;                                   /* Buffer counter */
+    int size;                                  /* Buffer size */
+    int *buffer;                               /* The buffer */
+} S64_IOB;
+#endif
+
 /* and finally... */
 #define PERL_PATCHLEVEL_H_IMPLICIT
 #include "patchlevel.h"
index 12c368d..2194653 100644 (file)
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -3724,6 +3724,9 @@ PP(pp_fork)
     if (childpid < 0)
        RETSETUNDEF;
     if (!childpid) {
+#ifdef SOCKS_64BIT_BUG
+       Perl_do_s64_init_buffer();
+#endif
        /*SUPPRESS 560*/
        if ((tmpgv = gv_fetchpv("$", TRUE, SVt_PV)))
            sv_setiv(GvSV(tmpgv), (IV)PerlProc_getpid());
diff --git a/proto.h b/proto.h
index 664336b..bec0bf5 100644 (file)
--- a/proto.h
+++ b/proto.h
@@ -248,13 +248,16 @@ PERL_CALLCONV UV  Perl_do_vecget(pTHX_ SV* sv, I32 offset, I32 size);
 PERL_CALLCONV void     Perl_do_vecset(pTHX_ SV* sv);
 PERL_CALLCONV void     Perl_do_vop(pTHX_ I32 optype, SV* sv, SV* left, SV* right);
 #if defined(SOCKS_64BIT_BUG)
-STATIC S64_IOB*        S_s64_get_buffer(pTHX_ PerlIO* fp);
 PERL_CALLCONV Off_t    Perl_do_s64_tell(PerlIO* fp);
 PERL_CALLCONV SSize_t  Perl_do_s64_fread(void *buf, SSize_t count, PerlIO* fp);
 PERL_CALLCONV int      Perl_do_s64_getc(PerlIO* fp);
 PERL_CALLCONV int      Perl_do_s64_seek(PerlIO* fp, Off_t pos, int whence);
 PERL_CALLCONV int      Perl_do_s64_ungetc(int ch, PerlIO* fp);
 PERL_CALLCONV void     Perl_do_s64_delete_buffer(PerlIO* fp);
+PERL_CALLCONV void     Perl_do_s64_init_buffer(void);
+STATIC S64_IOB *       S_s64_get_buffer(pTHX_ PerlIO *f);
+STATIC S64_IOB *       S_s64_create_buffer(pTHX_ PerlIO *f);
+STATIC int     S_s64_malloc(pTHX_ S64_IOB *ptr);
 #endif
 PERL_CALLCONV OP*      Perl_dofile(pTHX_ OP* term);
 PERL_CALLCONV I32      Perl_dowantarray(pTHX);
index 45c16c2..4ac4e35 100755 (executable)
@@ -156,6 +156,8 @@ if($pid = fork()) {
     if ($sock) {
        $sock->print("ok 11\n");
        $sock->print("quit\n");
+    } else {
+       print "not ok 11\n";
     }
     $sock = undef;
     sleep(1);