Corrected FILENO implementation to return undef if stream is closed otherwise -1.
[catagits/fcgi2.git] / perl / FCGI.xs
index 63bb247..c12e608 100644 (file)
@@ -29,7 +29,7 @@
 #define WIDE_CHAR_DEPRECATION_MSG "Use of wide characters in %s is deprecated" \
   " and will stop wprking in a future version of FCGI"
 
-#if defined(USE_LOCKING) && defined(USE_THREADS)
+#if defined(USE_ITHREADS)
 static perl_mutex accept_mutex;
 #endif
 
@@ -149,11 +149,11 @@ FCGI_Accept(FCGP_Request* request) {
         int acceptResult;
 
         FCGI_Finish(request);
-#if defined(USE_LOCKING) && defined(USE_THREADS)
+#if defined(USE_ITHREADS)
         MUTEX_LOCK(&accept_mutex);
 #endif
         acceptResult = FCGX_Accept_r(fcgx_req);
-#if defined(USE_LOCKING) && defined(USE_THREADS)
+#if defined(USE_ITHREADS)
         MUTEX_UNLOCK(&accept_mutex);
 #endif
         if(acceptResult < 0) {
@@ -233,7 +233,7 @@ FCGI_Release_Request(FCGP_Request *req) {
 
 static void
 FCGI_Init() {
-#if defined(USE_LOCKING) && defined(USE_THREADS)
+#if defined(USE_ITHREADS)
     dTHX;
     MUTEX_INIT(&accept_mutex);
 #endif
@@ -469,6 +469,24 @@ GETC(stream)
     else
         ST(0) = &PL_sv_undef;
 
+SV *
+EOF(stream, called=0)
+    FCGI::Stream stream;
+    IV called;
+  CODE:
+    RETVAL = boolSV(FCGX_HasSeenEOF(stream));
+  OUTPUT:
+    RETVAL
+
+void
+FILENO(stream)
+    FCGI::Stream stream;
+  CODE:
+    if (FCGX_HasSeenEOF(stream) != 0)
+        XSRETURN_UNDEF;
+    else
+        XSRETURN_IV(-1);
+
 bool
 CLOSE(stream)
     FCGI::Stream stream;