Glenn Strauss wrote:
On Wed, Aug 18, 2004 at 12:59:51PM -0700, Ken Simpson wrote:

the APR::Socket object is an opaque one, so it can't interoperate with any other perl modules. Have you looked if there is some C api to get the native socket object? There could be one (as they have for file objects), I didn't check.

I looked through apr_network_io.h, which seemed like the logical place, and couldn't find an API that returns the native socket object. But I'm pretty unfamiliar with the Apache code base, so someone else would probably have better luck.


This is what we'd need bound to the Perl API:

apr_os_sock_t fd;
apr_os_sock_get((apr_os_sock_t *) &fd, (apr_socket_t *) client_socket);

ok, I've looked at APR::Poll and it'll require time to expose it, which I don't have at the moment. So you can try to do it yourselves or remind us to do that later (probably after 2.0 release).


Meanwhile, the following patch (against the current cvs) will give you the fd as Glenn has suggested, you'd use it as:

use APR::OS ();
my $fd = APR::OS::sock_get($c->client_socket);
warn "got: socket fd $fd\n";

Most likely this won't become part of the API for the reasons discussed so far in this thread (portability), but it should get you going for now.

Index: xs/APR/OS/APR__OS.h
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/APR/OS/APR__OS.h,v
retrieving revision 1.3
diff -u -r1.3 APR__OS.h
--- xs/APR/OS/APR__OS.h 4 Mar 2004 06:01:09 -0000 1.3
+++ xs/APR/OS/APR__OS.h 18 Aug 2004 23:28:27 -0000
@@ -21,3 +21,12 @@
return 0;
#endif
}
+
+static MP_INLINE int mpxs_APR__OS_sock_get(pTHX_ apr_socket_t *socket)
+{
+ apr_os_sock_t fd;
+ MP_RUN_CROAK(apr_os_sock_get(&fd, socket),
+ "APR::OS::sock_get");
+
+ return (int)fd;
+}
Index: xs/maps/apr_functions.map
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/maps/apr_functions.map,v
retrieving revision 1.83
diff -u -r1.83 apr_functions.map
--- xs/maps/apr_functions.map 15 Jul 2004 06:23:21 -0000 1.83
+++ xs/maps/apr_functions.map 18 Aug 2004 23:28:27 -0000
@@ -613,7 +613,8 @@
-apr_os_exp_time_get
-apr_os_file_get
-apr_os_imp_time_get
--apr_os_sock_get
+~apr_os_sock_get
+ mpxs_APR__OS_sock_get
-apr_os_thread_get
-apr_os_threadkey_get
-apr_os_sock_make
Index: xs/tables/current/ModPerl/FunctionTable.pm
===================================================================
RCS file: /home/cvs/modperl-2.0/xs/tables/current/ModPerl/FunctionTable.pm,v
retrieving revision 1.173
diff -u -r1.173 FunctionTable.pm
--- xs/tables/current/ModPerl/FunctionTable.pm 16 Jul 2004 01:10:46 -0000 1.173
+++ xs/tables/current/ModPerl/FunctionTable.pm 18 Aug 2004 23:28:27 -0000
@@ -2,7 +2,7 @@


 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
 # ! WARNING: generated by ModPerl::ParseSource/0.01
-# !          Thu Jul 15 16:55:01 2004
+# !          Wed Aug 18 16:07:19 2004
 # !          do NOT edit, any changes will be lost !
 # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

@@ -1799,6 +1799,24 @@
     ]
   },
   {
+    'return_type' => 'void',
+    'name' => 'modperl_errsv_prepend',
+    'args' => [
+      {
+        'type' => 'PerlInterpreter *',
+        'name' => 'my_perl'
+      },
+      {
+        'type' => 'const char *',
+        'name' => 'pat'
+      },
+      {
+        'type' => '...',
+        'name' => 'arg2'
+      }
+    ]
+  },
+  {
     'return_type' => 'char *',
     'name' => 'modperl_file2package',
     'args' => [
@@ -5466,6 +5484,24 @@
       {
         'type' => 'apr_pool_t *',
         'name' => 'p'
+      }
+    ]
+  },
+  {
+    'return_type' => 'int',
+    'name' => 'mpxs_APR__OS_sock_get',
+    'attr' => [
+      'static',
+      '__inline__'
+    ],
+    'args' => [
+      {
+        'type' => 'PerlInterpreter *',
+        'name' => 'my_perl'
+      },
+      {
+        'type' => 'apr_socket_t *',
+        'name' => 'socket'
       }
     ]
   },


-- __________________________________________________________________ Stas Bekman JAm_pH ------> Just Another mod_perl Hacker http://stason.org/ mod_perl Guide ---> http://perl.apache.org mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com http://modperlbook.org http://apache.org http://ticketmaster.com

--
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html



Reply via email to