Removed support for SFIO
chansen [Sun, 29 Aug 2010 22:36:56 +0000 (00:36 +0200)]
perl/FCGI.XL

index cc3536f..109ec6f 100644 (file)
@@ -38,61 +38,6 @@ __END__
 #define INT2PTR(a,b) ((a) (b))
 #endif
 
-#ifdef USE_SFIO
-typedef struct
-{
-    Sfdisc_t    disc;
-    FCGX_Stream *stream;
-} FCGI_Disc;
-
-static ssize_t
-sffcgiread(f, buf, n, disc)
-Sfio_t*     f;      /* stream involved */
-Void_t*     buf;    /* buffer to read into */
-size_t      n;      /* number of bytes to read */
-Sfdisc_t*   disc;   /* discipline */
-{
-    return FCGX_GetStr(buf, n, ((FCGI_Disc *)disc)->stream);
-}
-
-static ssize_t
-sffcgiwrite(f, buf, n, disc)
-Sfio_t*     f;      /* stream involved */
-const Void_t*   buf;    /* buffer to read into */
-size_t      n;      /* number of bytes to read */
-Sfdisc_t*   disc;   /* discipline */
-{
-    n = FCGX_PutStr(buf, n, ((FCGI_Disc *)disc)->stream);
-    FCGX_FFlush(((FCGI_Disc *)disc)->stream);
-    return n;
-}
-
-Sfdisc_t *
-sfdcnewfcgi(stream)
-    FCGX_Stream *stream;
-{
-    FCGI_Disc*  disc;
-
-    New(1000,disc,1,FCGI_Disc);
-    if (!disc) return (Sfdisc_t *)disc;
-
-    disc->disc.exceptf = (Sfexcept_f)NULL;
-    disc->disc.seekf = (Sfseek_f)NULL;
-    disc->disc.readf = sffcgiread;
-    disc->disc.writef = sffcgiwrite;
-    disc->stream = stream;
-    return (Sfdisc_t *)disc;
-}
-
-Sfdisc_t *
-sfdcdelfcgi(disc)
-    Sfdisc_t*   disc;
-{
-    Safefree(disc);
-    return 0;
-}
-#endif
-
 #if defined(USE_LOCKING) && defined(USE_THREADS)
 static perl_mutex accept_mutex;
 #endif
@@ -106,10 +51,6 @@ typedef struct FCGP_Request {
     GV*         gv[3];
     HV*         hvEnv;
     FCGX_Request*   requestPtr;
-#ifdef USE_SFIO
-    int         sfcreated[3];
-    IO*         io[3];
-#endif
 } FCGP_Request;
 
 static void FCGI_Finish(FCGP_Request* request);
@@ -119,32 +60,21 @@ FCGI_Flush(FCGP_Request* request) {
     dTHX;
     if(!request->bound)
         return;
-#ifdef USE_SFIO
-    sfsync(IoOFP(GvIOp(request->gv[1])));
-    sfsync(IoOFP(GvIOp(request->gv[2])));
-#else
     FCGX_FFlush(INT2PTR(FCGX_Stream *, SvIV((SV*) SvRV(request->svout))));
     FCGX_FFlush(INT2PTR(FCGX_Stream *, SvIV((SV*) SvRV(request->sverr))));
-#endif
 }
 
 static void
 FCGI_UndoBinding(FCGP_Request* request) {
     dTHX;
-#ifdef USE_SFIO
-    sfdcdelfcgi(sfdisc(IoIFP(request->io[0]), SF_POPDISC));
-    sfdcdelfcgi(sfdisc(IoOFP(request->io[1]), SF_POPDISC));
-    sfdcdelfcgi(sfdisc(IoOFP(request->io[2]), SF_POPDISC));
-#else
-#  ifdef USE_PERLIO
+#ifdef USE_PERLIO
     sv_unmagic((SV *)GvIOp(request->gv[0]), 'q');
     sv_unmagic((SV *)GvIOp(request->gv[1]), 'q');
     sv_unmagic((SV *)GvIOp(request->gv[2]), 'q');
-#  else
+#else
     sv_unmagic((SV *)request->gv[0], 'q');
     sv_unmagic((SV *)request->gv[1], 'q');
     sv_unmagic((SV *)request->gv[2], 'q');
-#  endif
 #endif
     request->bound = FALSE;
 }
@@ -152,12 +82,7 @@ FCGI_UndoBinding(FCGP_Request* request) {
 static void
 FCGI_Bind(FCGP_Request* request) {
     dTHX;
-#ifdef USE_SFIO
-    sfdisc(IoIFP(request->io[0]), sfdcnewfcgi(request->requestPtr->in));
-    sfdisc(IoOFP(request->io[1]), sfdcnewfcgi(request->requestPtr->out));
-    sfdisc(IoOFP(request->io[2]), sfdcnewfcgi(request->requestPtr->err));
-#else
-#  ifdef USE_PERLIO
+#ifdef USE_PERLIO
     /* For tied filehandles, we apply tiedscalar magic to the IO
        slot of the GP rather than the GV itself. */
 
@@ -171,11 +96,10 @@ FCGI_Bind(FCGP_Request* request) {
     sv_magic((SV *)GvIOp(request->gv[1]), request->svout, 'q', Nullch, 0);
     sv_magic((SV *)GvIOp(request->gv[2]), request->sverr, 'q', Nullch, 0);
     sv_magic((SV *)GvIOp(request->gv[0]), request->svin, 'q', Nullch, 0);
-#  else
+#else
     sv_magic((SV *)request->gv[1], request->svout, 'q', Nullch, 0);
     sv_magic((SV *)request->gv[2], request->sverr, 'q', Nullch, 0);
     sv_magic((SV *)request->gv[0], request->svin, 'q', Nullch, 0);
-#  endif
 #endif
     request->bound = TRUE;
 }
@@ -230,9 +154,6 @@ FCGI_Accept(FCGP_Request* request) {
         been_here = 1;
     } 
     else {
-#ifdef USE_SFIO
-        int i;
-#endif
         FCGX_Request *fcgx_req = request->requestPtr;
         int acceptResult;
 
@@ -250,19 +171,6 @@ FCGI_Accept(FCGP_Request* request) {
 
         populate_env(fcgx_req->envp, request->hvEnv);
 
-#ifdef USE_SFIO
-        for (i = 0; i < 3; ++i) {
-            request->io[i] = GvIOn(request->gv[i]);
-            if (!(i == 0 ? IoIFP(request->io[i]) : IoOFP(request->io[i]))) {
-                IoIFP(request->io[i]) = sftmp(0);
-                /*IoIFP(request->io[i]) = sfnew(NULL, NULL, SF_UNBOUND, 0, 
-                     SF_STRING | (i ? SF_WRITE : SF_READ));*/
-                if (i != 0) 
-                    IoOFP(request->io[i]) = IoIFP(request->io[i]);
-                request->sfcreated[i] = TRUE;
-            }
-        }
-#else
         if (!request->svout) {
             newSVrv(request->svout = newSV(0), "FCGI::Stream");
             newSVrv(request->sverr = newSV(0), "FCGI::Stream");
@@ -271,7 +179,6 @@ FCGI_Accept(FCGP_Request* request) {
         sv_setiv(SvRV(request->svout), INT2PTR(IV, fcgx_req->out));
         sv_setiv(SvRV(request->sverr), INT2PTR(IV, fcgx_req->err));
         sv_setiv(SvRV(request->svin), INT2PTR(IV, fcgx_req->in));
-#endif
         FCGI_Bind(request);
         request->accepted = TRUE;
     }
@@ -280,9 +187,6 @@ FCGI_Accept(FCGP_Request* request) {
 
 static void 
 FCGI_Finish(FCGP_Request* request) {
-#ifdef USE_SFIO
-    int i;
-#endif
     int was_bound;
     dTHX;
 
@@ -291,15 +195,6 @@ FCGI_Finish(FCGP_Request* request) {
 
     if (was_bound = request->bound)
         FCGI_UndoBinding(request);
-#ifdef USE_SFIO
-    for (i = 0; i < 3; ++i) {
-        if (request->sfcreated[i]) {
-            sfclose(IoIFP(request->io[i]));
-            IoIFP(request->io[i]) = IoOFP(request->io[i]) = Nullfp;
-            request->sfcreated[i] = FALSE;
-        }
-    }
-#endif
     if (was_bound)
         FCGX_Finish_r(request->requestPtr);
     else
@@ -476,8 +371,6 @@ DESTROY(request)
 
 MODULE = FCGI PACKAGE = FCGI::Stream
 
-#ifndef USE_SFIO
-
 SV *
 PRINT(stream, ...)
     FCGI::Stream stream;
@@ -576,5 +469,3 @@ CLOSE(stream)
     RETVAL = FCGX_FClose(stream) != -1;
   OUTPUT:
     RETVAL
-
-#endif