Re: debugging a timeout issue

2008-05-08 Thread Subra A Narayanan
Hey Sam,

I am not an apache expert but you can start off with a tool like wireshark
to see if the request is even leaving the client machine. Its a great tool
to debug such problems.

Subra

On Thu, May 8, 2008 at 10:24 PM, Sam Carleton [EMAIL PROTECTED]
wrote:

 I am a one man ISV that is using an Apache and an Apache Module.  I am
 trying to trouble shoot a timeout issue that I cannot see, my customer
 is reporting the problem and he can consistently repeat the problem.
 Sometimes when the .Net 2.0 client makes a call to my Apache module,
 the .Net code times out, I am trying to figure out which side is
 having problems.  I am thinking it is a .Net, but I wanted to make
 sure that I throughly confirmed that it is not Apache.

 I have logged the heck out of my apache module and it never gets called.
 I have set apache's LogLevel to debug and turned on access logging,
 but I never see the request come in.  I see the first one, but not the
 second one.

 Is there anything else I can do to increase the logging of Apache or
 is it safe to say that the request is NOT leaving the .Net
 application?  Any suggestions on how I can absolutely confirm the
 issue is in the .Net client?

 Sam



module clean up using apr_pool_cleanup_register

2008-05-07 Thread Subra A Narayanan
Hello folks,

I am new to apache modules and I am trying to get a better understanding of
how cleanup works. I have Nick Kew's book and it has been a tremendous help.
I hope someone can hep clarify some of the questions that I have.

I have written a module which links in to some other libraries that I have.
In my_module_init from below:

ap_hook_child_init(my_module_init, NULL, NULL, APR_HOOK_MIDDLE);


I call the initialization routines for my own libraries. Also in init, I
register a cleanup function like this:

apr_pool_cleanup_register(pool, (const void*)svr_rec, my_child_exit,
apr_pool_cleanup_null);


In the my_child_exit function, all I do is call my library's finalize
function to clean up resources.

Is this the right way to do the clean up? Instead of the above line of code,
should I be passing NULL as the second argument for the
apr_pool_cleanup_register function like I have seen in some of the examples
on the web:

apr_pool_cleanup_register(pool, NULL, my_child_exit,
apr_pool_cleanup_null);


Thanks,
Subra


Reading data from Request Body - Twice!!

2008-05-02 Thread Subra A Narayanan
Hello folks,

I really hope someone can point me in the correct direction here.

I have an apache module that receives data from clients in the request body
and saves the recvd data in a db. The client also sends the Content-MD5
header with the request which I want to verify by computing the MD5 of recvd
data and checking if the result is the same as the value of the Content-MD5
header. I want to just discard the data (not store it in the db) and return
an error if the MD5 check fails.

The client can send up to 4 GB data in the request. Which means I will have
to compute the MD5 incrementally in small chunks using the MD5_INIT,
MD5_UPDATE and MD5_FINAL routines. But this means that I would have already
read the request body once from start to end using the following functions:

ap_setup_client_block(request_rechttp://httpd.apache.org/dev/apidoc/apidoc_request_rec.html*r,
int read_policy);
ap_should_client_block(request_rechttp://httpd.apache.org/dev/apidoc/apidoc_request_rec.html*r);
ap_get_client_block(request_rechttp://httpd.apache.org/dev/apidoc/apidoc_request_rec.html*r,
char *buffer, int bufsiz);


Now if the MD5 checksum passes and now I want to read the data again, how
would i do it? I cannot use the above function again, right?
'ap_should_client_block' has already told the client once to send the entire
data once.

Reading the data once, computing the MD5, caching it and then reusing the
cached data if the checksum passes is one option, but I dont want to do that
for a variety of reasons.

Is there any other way?

Thanks for any help.

Subra


Re: Sending large file as attachment to clients

2008-03-25 Thread Subra A Narayanan
Thanks for the replies guys. I will try ur suggestions once I get to work
today. Just a few more questions:



 Check out the various filter/bucket brigade examples. This may do just
 what you want. I've used it to 'gate' the final sending for things ike
 throttling and keeping buggy telco bearer boxes happy.


Dirk: Do you remember any filter/bucket off the top of ur head that I can
look at?



 Samuel was aiming the right direction.  If you can read in pieces of the
 data to send, you should be able to loop over that reading a chunk of
 data, then sending it, then reading a chunk the same size (same block,
 for example), and continuing until the data has been sent.  Try that to
 see if you obtain a different result.


Joe: Do you mean this:

while(!EOF)
{
   Read chunk of data;
   ap_rwrite(objBuffer, bufferLen, request);
}

Can I use the ap_rwrite function for sending chunks of data too? Or should I
be using some other function in the API for this?

I will test out these suggestions and report my findings asap.

Thanks!


Re: Sending large file as attachment to clients

2008-03-24 Thread Subra A Narayanan
Thanks for ur reply Samuel!

Maybe you can read part of the blob with a function like MySQL's SUBSTR.


I can easily read small chunks of data from my datastore. I guess the
problem that I am trying to solve here - how to send chunks of data as a
HTTP response without having to read in and store a large file/object in
memory.


Subra


Re: Specifying a different target directory for APXS

2007-12-14 Thread Subra A Narayanan
Hello folks,

Has anyone come across a similar situation before? Can a target folder be
specified or is that not possible?

Any help is greatly appreciated.

Subra

On Dec 13, 2007 12:05 PM, Subra A Narayanan [EMAIL PROTECTED] wrote:

 Hello folks,

 I use the following command to compile my apache module:

 */usr/sbin/apxs -c mod_my.c*


 this creates a *.libs/* folder and my mod_my.so file is generated in that
 folder.

 My question is, is it possible to specify a different target folder for my
 .so file?

 I have gone through the man page for apxs and wasn't able to find
 anything.


 thanks in advance,
 Subra



Re: Specifying a different target directory for APXS

2007-12-14 Thread Subra A Narayanan
Joe,

Thanks for ur reply.

Let me clarify somethingWhen I said I didnt get any helpful responses, I
meant I didn't get any answers as to what is wrong with gcc and why the
module was behaving the way it was.

Anywayspoint taken.will use apxs for compiling the module.

Subra

On Dec 14, 2007 12:12 PM, Joe Lewis [EMAIL PROTECTED] wrote:

 Subra A Narayanan wrote:
  I didnt receive any helpful responses to that posting thats why I am
 trying
  to use apxs.
 

 You DID get helpful responses - I was one of those responders who said
 to use apxs.  (We pointed you to the tool because there are too many
 changes across systems, platforms, etc, that it is faster, more
 efficient, and better quality to use a tool that also makes the end
 result more portable - go figure).

  Would you care to take a look at this issue =
 
 http://mail-archives.apache.org/mod_mbox/httpd-modules-dev/200711.mbox/[EMAIL 
 PROTECTED]
 

 We need no more discussion on that - use apxs.  If you need a Makefile,
 use the apxs tool in your Makefile.  (It IS possible, after all.)  For
 example, Makefile rules might look like :

 mod_test.so:
apxs -c mod_test.so
cp .libs/mod_test.so path/to/mod_test.so

 install:
apxs -n mod_test -i mod_test.la

 That is how I have done all of my modules.  It's easier to type make
 install rather than apxs -i -a -c mod_test.c.  If you think you need
 help in your makefile, go to google, and type in makefile.  Just
 copying a makefile from another package seriously limits your
 capabilities.

 Joe
 --
 Joseph Lewis http://sharktooth.org/
 Divide the fire, and you will sooner put it out. - Publius Syrus



Re: Specifying a different target directory for APXS

2007-12-14 Thread Subra A Narayanan
Ralf/Joe,

Now I am trying to (just) compile my module using apxs and I see this
warning

 *$ /usr/sbin/apxs -c -L /myprj/deps/axis2c/lib -L /myprj/lib/ -l
axutil -l axis2_engine -l dl -l pthread -l client -l operations -c
/myprj/obj/webservices/mod_my.o /myprj/obj/webservices/dispatcher.o
/myprj/obj/webservices/parserequest.o
/myprj/obj/webservices/response.o
/usr/lib/apr/build/libtool --silent --mode=link gcc -o
/myprj/obj/webservices/mod_my.la  -L /myprj/deps/axis2c/lib
-L/myprj/lib/ -laxutil -laxis2_engine -ldl -lpthread -lclient
-loperations -rpath /usr/lib/httpd/modules -module -avoid-version
/myprj/obj/webservices/mod_my.o /myprj/obj/webservices/dispatcher.o
/myprj/obj/webservices/parserequest.o
/myprj/obj/webservices/response.o

*** Warning: Linking the shared library
/myprj/obj/webservices/mod_my.la against the non-libtool
*** objects  /myprj/obj/webservices/mod_my.o
/myprj/obj/webservices/dispatcher.o
/myprj/obj/webservices/parserequest.o
/myprj/obj/webservices/response.o is not portable!*


Do you know what is causing this problem?

Thanks for all the responses!
Subra


On Dec 14, 2007 1:30 PM, Ralf Mattes [EMAIL PROTECTED] wrote:

 On Fri, 2007-12-14 at 11:05 -0500, Subra A Narayanan wrote:
  Joe,
 
  Thanks for ur response.
 
  The reason I wanted to change the target directory was because my apache
  module is being compiled as one of the components of a much larger
 makefile.
  All the other shared libraries generated by this make file, are copied
 in a
  particular directory and hence I wanted my apache module to go in to
 that
  directory as well. As you suggested, I could copy the .so file to
 whatever
  directory I want later on, but I am not sure if such copying ig
 generally
  done in a makefile.

 That's the approach I would choose (I do for packaging my modules into
 Debian packages). Why wouldn't you copy in a Makefile? Just add another
 dependency:

 your_very_Special_path/your_module.so: your_module.slo
cp .libs/your_module.so
 your_very_Special_path/your_module.so


  I did try to directly use gcc to compile my apache module so that I
 could
  specify any target directory but ran in to another issue which is
 detailed
  here =
 
 http://mail-archives.apache.org/mod_mbox/httpd-modules-dev/200711.mbox/[EMAIL 
 PROTECTED]
 
  I didnt receive any helpful responses to that posting thats why I am
 trying
  to use apxs.

 I got the impression that everyone considered this a no-so-good
 idea 

  HTH Ralf Mattes




Specifying a different target directory for APXS

2007-12-13 Thread Subra A Narayanan
Hello folks,

I use the following command to compile my apache module:

*/usr/sbin/apxs -c mod_my.c*


this creates a *.libs/* folder and my mod_my.so file is generated in that
folder.

My question is, is it possible to specify a different target folder for my
.so file?

I have gone through the man page for apxs and wasn't able to find anything.


thanks in advance,
Subra


Re: compiling using gcc directly rather than using apxs

2007-11-28 Thread Subra A Narayanan
Here you go Karim.

On Nov 28, 2007 1:23 PM, karim Bendadda [EMAIL PROTECTED] wrote:

 You have forgotten to attach your module can you do it please?

 2007/11/28, Subra A Narayanan [EMAIL PROTECTED]:
 
  I am still not able to figure out the problem. For longtime module
  developers, this should be a simple problem to solve.
 
  Any pointers in the right direction would be greatly appreciated.
 
  Subra
 
  On Nov 27, 2007 1:21 PM, Subra A Narayanan [EMAIL PROTECTED] wrote:
 
   Hello folks,
  
   I have run in to a problem and hope someone can help me out. I am
 using
   Apache HTTP server version 2.0.61
  
   I have written a simple test module called mod_my.c in which all I do
 is
   printout the contents of  request-parsed_uri structure which if of
 type
   apr_uri_t.
   The module works just fine when I use the following command to compile
  and
   install it:
   *$ /usr/sbin/apxs -c mod_my.c
   $ /usr/sbin/apxs -i mod_my.la
   *
   But if I use my own make file to compile the module, I see that the
   members of the apr_uri_t are either null or incorrectly populated.
 Here
  is
   the command I use to compile
   *$ gcc -Wall -Werror -fPIC -D_REENTRANT -Di686 -D_FILE_OFFSET_BITS=64
 -g
   -I /usr/include/httpd -I /usr/include/apr-0 -c mod_my.c -o mod_my.o
   $ gcc -fPIC -static-libgcc -shared -z initfirst ./mod_my.o -o
  ./mod_my.so
   *
  
   I know for sure that the problem is with the way I am compiling the
   module. Can anyone tell me what am I missing here?
  
   I am also attaching my module file for your reference.
  
   Thanks,
   Subra
  
  
  
 



 --
 Karim Bendadda



compiling using gcc directly rather than using apxs

2007-11-27 Thread Subra A Narayanan
Hello folks,

I have run in to a problem and hope someone can help me out. I am using
Apache HTTP server version 2.0.61

I have written a simple test module called mod_my.c in which all I do is
printout the contents of  request-parsed_uri structure which if of type
apr_uri_t.
The module works just fine when I use the following command to compile and
install it:
*$ /usr/sbin/apxs -c mod_my.c
$ /usr/sbin/apxs -i mod_my.la
*
But if I use my own make file to compile the module, I see that the members
of the apr_uri_t are either null or incorrectly populated. Here is the
command I use to compile
*$ gcc -Wall -Werror -fPIC -D_REENTRANT -Di686 -D_FILE_OFFSET_BITS=64 -g -I
/usr/include/httpd -I /usr/include/apr-0 -c mod_my.c -o mod_my.o
$ gcc -fPIC -static-libgcc -shared -z initfirst ./mod_my.o -o ./mod_my.so
*

I know for sure that the problem is with the way I am compiling the module.
Can anyone tell me what am I missing here?

I am also attaching my module file for your reference.

Thanks,
Subra