You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by 张 臻博 <la...@hotmail.com> on 2007/02/06 20:53:34 UTC
questions related to compile!
hello,
Currently, I am writing one module for Apache. I build this module by using
apxs. Meanwhile, i have also made changes to the Apache server source code,
e.g. in prefork.c. By making modification, I have to use one data structure
that is defined in the module source code.
Now i have the problem: when i do the compilation, prefork.c can not refer
to the file that i made.(because it will be made as a DSO after Apache
server comiplation) So the data structure that i made is unrecognized. How
can i include the source file that i made in the Apache server comiplation
process, while the module is still built as a DSO by using apxs.
Hope i have describe the problem clearly. Is there some professionals who
can give me help? Thanks a lot.
br
frnakie
_________________________________________________________________
与世界各地的朋友进行交流,免费下载 Live Messenger;
http://get.live.com/messenger/overview
Re: questions related to compile!
Posted by 张 臻博 <la...@hotmail.com>.
>>>>How can i include the source file that i made in the Apache
>>>>server comiplation process, while the module is still built as a
>>>> DSO by using apxs
>>>
>>>You would have to declare the structure in a header file, which
>>>you #include in both your module source code and in the Apache
>>>source file where you reference it. Then, when you configure
>>>httpd, you can tell it where your header file lives by passing an
>>> environment variable, like:
>>>
>>>CFLAGS="-I/path/to/your/module/source" ./configure ...
>>Thanks a lot to your kindly reply. The structure is declared in the
>> header file, however, it is initialized in the C source file(.c)
>>in the module part during the process of create_server_config. If
>>i just include the header file, will it work?
>>
>>Please let me describe what i want to do in a bit more detail.
>>Actually i try to implement a different layer to handle http
>>request&response. In the module part, in the header file i will
>>declare and in the c source file i will initialize a socket
>>structure that is different from the normal tcp socket structure.
>>(ap_listen_rec *ap_listeners). This new socket structure will be
>>used in the prefork.c & pollset.c during the polling procedure.
>>That is why i have to include the source file in the comiplation
>>procedure. What should be the best way to handle this situation?
>>After the polling process, if the tcp socket is selected, then the
>>normal procedure handling the http request will be followed.
>>(ap_run_create_connection,ap_process_connection). If another type
>>of socket that is implemented by me is selected then one module in
>>my module will be called. The data will be read from this socket
>>and parsed to the normal http request. Then I will try to call the
>>(ap_rn_pre_connection,ap_run_process_connection) hook again. Before
>> sending back the resources, i will try to patch them back to the
>>data structure that is suitable for my layer's communication and
>>send it back. I am now just in the step implementing the new
>>polling procedure. Would you please give me some comments that will
>> be helpful for me to realize the goal(any comments will be
>>beneficial both in the polling process and the whole feature)?
>
>It sounds almost like you might want to write your own MPM, and
>incorporate your code and data structure into that instead of
>calling back to another module.
Actually i am not planning writing my own MPM, because i still need the tcp
socket to handle the http request coming by normal way. I just modify part
of code in prefork.c & pollset.c to modify the way in polling process. I
haven't seen any reason to write a totally new MPM. Or you think that it is
necessary?
>
><..>
>>I just wonder if i successfully realize this feature. Is it
>>possible to include the modification to the new release of Apache
>>http server.
>
>We welcome contributions to Apache, and have a page of guidelines
>for contributors:
>
>http://httpd.apache.org/dev/patches.html
>
>However, I would like to add some remarks that are my personal
>opinion, but I think reflect the attitude of the project
>contributors:
>
>* We can only consider contributions in the form of source code. We
> can encourage ideas, but cannot make a decision based on anything
> but code patches
>
>* For us to accept a patch, we will consider whether it serves a
>general
> need, and whether it will be used by Apache users other than
>yourself
>
>* We will also look at the design and implementation of the patch,
>and
> how cleanly it applies to Apache (hint: making APR dependent on
> httpd would not be a good idea, see below)
>
>* Apache 2.2.x is a stable/maintenance branch, and we are not
>putting
> any new features into it. New features and improvements go into
>the
> development trunk at:
>
> http://svn.apache.org/repos/asf/httpd/httpd/trunk
>
>* Finally, if the patch is large, or implements a significant new
>idea,
> we need to be certain that it can be maintained. This means that
>we
> need to fully understand what it does and how it works, or be
>sure
> that the contributor is an active member of the development
> community. Anyone can become part of the development community by
> participating in the dev@httpd.apache.org mailinglist, submitting
> patches to fix bugs, testing releases and generally participating
> in the discussion. To judge whether someone is an active
>contributor,
> we look back at their past submissions and contributions
I will try to dedicate more time to apache developing. Hope the
implementation can be finished asap.
>Regarding the header problem you describe in your other message, it
>looks like you included your module header file in an APR source
>file, and your build failed when compiling part of APR. This
>happened because the APR build couldn't find the httpd headers that
>your header file includes... when you look back at the build output
>you posted you'll see that there is no reference to include
>directories under httpd. The -I./include applies to srclib/apr/
>include, because that is where that build happens. You would
>probably better include those httpd headers from your C source file
>than from your header file.
>
>Also, APR, the Apache Portable Runtime, is a library that is called
>(extensively) by the Apache source, but it is completely separate
>from httpd itself, and only bundled with httpd releases for
>convenience. APR knows nothing about the applications (like httpd)
>that use it, and this must remain so because of the code design.
Thanks a lot for your comment. It is just the problem that i have. I also
found i can not use AP_DECLARE_HOOK or AP_IMPLEMENT_RUN_FIRST, this kind of
hook stuff in module. I have to make couple of new hooks. Now i put the
declaration AP_DECLARE_HOOK in http_connection.h together with similar
create_connection, process_connection hook. And put AP_IMPLEMENT_RUN_FIRST
in the place where i use it.(e.g. prefork.c). At leaset now the compilation
process passed. I have to check whether it actally works.
Again, thanks a lot for your hint. They are really helpful!
br
frankie
_________________________________________________________________
与联机的朋友进行交流,请使用 MSN Messenger: http://messenger.msn.com/cn
Re: questions related to compile!
Posted by Sander Temme <sc...@apache.org>.
On Feb 6, 2007, at 11:54 PM, 张 臻博 wrote:
> hello!
>
>>> How can i include the source file that i made in the Apache
>>> server comiplation process, while the module is still built as a
>>> DSO by using apxs
>>
>> You would have to declare the structure in a header file, which
>> you #include in both your module source code and in the Apache
>> source file where you reference it. Then, when you configure
>> httpd, you can tell it where your header file lives by passing an
>> environment variable, like:
>>
>> CFLAGS="-I/path/to/your/module/source" ./configure ...
> Thanks a lot to your kindly reply. The structure is declared in the
> header file, however, it is initialized in the C source file(.c) in
> the module part during the process of create_server_config. If i
> just include the header file, will it work?
>
> Please let me describe what i want to do in a bit more detail.
> Actually i try to implement a different layer to handle http
> request&response. In the module part, in the header file i will
> declare and in the c source file i will initialize a socket
> structure that is different from the normal tcp socket structure.
> (ap_listen_rec *ap_listeners). This new socket structure will be
> used in the prefork.c & pollset.c during the polling procedure.
> That is why i have to include the source file in the comiplation
> procedure. What should be the best way to handle this situation?
> After the polling process, if the tcp socket is selected, then the
> normal procedure handling the http request will be followed.
> (ap_run_create_connection,ap_process_connection). If another type
> of socket that is implemented by me is selected then one module in
> my module will be called. The data will be read from this socket
> and parsed to the normal http request. Then I will try to call the
> (ap_rn_pre_connection,ap_run_process_connection) hook again. Before
> sending back the resources, i will try to patch them back to the
> data structure that is suitable for my layer's communication and
> send it back. I am now just in the step implementing the new
> polling procedure. Would you please give me some comments that will
> be helpful for me to realize the goal(any comments will be
> beneficial both in the polling process and the whole feature)?
It sounds almost like you might want to write your own MPM, and
incorporate your code and data structure into that instead of calling
back to another module.
Anyone else have an opinion on this?
<..>
> I just wonder if i successfully realize this feature. Is it
> possible to include the modification to the new release of Apache
> http server.
We welcome contributions to Apache, and have a page of guidelines for
contributors:
http://httpd.apache.org/dev/patches.html
However, I would like to add some remarks that are my personal
opinion, but I think reflect the attitude of the project contributors:
* We can only consider contributions in the form of source code. We
can encourage ideas, but cannot make a decision based on anything
but code patches
* For us to accept a patch, we will consider whether it serves a general
need, and whether it will be used by Apache users other than yourself
* We will also look at the design and implementation of the patch, and
how cleanly it applies to Apache (hint: making APR dependent on
httpd would not be a good idea, see below)
* Apache 2.2.x is a stable/maintenance branch, and we are not putting
any new features into it. New features and improvements go into the
development trunk at:
http://svn.apache.org/repos/asf/httpd/httpd/trunk
* Finally, if the patch is large, or implements a significant new idea,
we need to be certain that it can be maintained. This means that we
need to fully understand what it does and how it works, or be sure
that the contributor is an active member of the development
community. Anyone can become part of the development community by
participating in the dev@httpd.apache.org mailinglist, submitting
patches to fix bugs, testing releases and generally participating
in the discussion. To judge whether someone is an active contributor,
we look back at their past submissions and contributions
> Any comments are greatly appreciated. Thanks a lot in advance!
Regarding the header problem you describe in your other message, it
looks like you included your module header file in an APR source
file, and your build failed when compiling part of APR. This
happened because the APR build couldn't find the httpd headers that
your header file includes... when you look back at the build output
you posted you'll see that there is no reference to include
directories under httpd. The -I./include applies to srclib/apr/
include, because that is where that build happens. You would
probably better include those httpd headers from your C source file
than from your header file.
Also, APR, the Apache Portable Runtime, is a library that is called
(extensively) by the Apache source, but it is completely separate
from httpd itself, and only bundled with httpd releases for
convenience. APR knows nothing about the applications (like httpd)
that use it, and this must remain so because of the code design.
S.
--
sctemme@apache.org http://www.temme.net/sander/
PGP FP: 51B4 8727 466A 0BC3 69F4 B7B8 B2BE BC40 1529 24AF
Re: questions related to compile!
Posted by 张 臻博 <la...@hotmail.com>.
hello!
>>How can i include the source file that i made in the Apache server
>>comiplation process, while the module is still built as a DSO by
>>using apxs
>
>You would have to declare the structure in a header file, which you
>#include in both your module source code and in the Apache source
>file where you reference it. Then, when you configure httpd, you can
> tell it where your header file lives by passing an environment
>variable, like:
>
>CFLAGS="-I/path/to/your/module/source" ./configure ...
Thanks a lot to your kindly reply. The structure is declared in the header
file, however, it is initialized in the C source file(.c) in the module
part during the process of create_server_config. If i just include the
header file, will it work?
Please let me describe what i want to do in a bit more detail. Actually i
try to implement a different layer to handle http request&response. In the
module part, in the header file i will declare and in the c source file i
will initialize a socket structure that is different from the normal tcp
socket structure.(ap_listen_rec *ap_listeners). This new socket structure
will be used in the prefork.c & pollset.c during the polling procedure.
That is why i have to include the source file in the comiplation procedure.
What should be the best way to handle this situation?
After the polling process, if the tcp socket is selected, then the normal
procedure handling the http request will be
followed.(ap_run_create_connection,ap_process_connection). If another type
of socket that is implemented by me is selected then one module in my
module will be called. The data will be read from this socket and parsed to
the normal http request. Then I will try to call the
(ap_rn_pre_connection,ap_run_process_connection) hook again. Before sending
back the resources, i will try to patch them back to the data structure
that is suitable for my layer's communication and send it back. I am now
just in the step implementing the new polling procedure. Would you please
give me some comments that will be helpful for me to realize the goal(any
comments will be beneficial both in the polling process and the whole
feature)?
>
>It is of course entirely up to you how you design your module and
>its interaction with the core, and we cannot make any assumptions
>about your particular requirements. However, you must realize that
> modifying the httpd core ties your module completely to that
>modified version of Apache: anyone who wants to use it must patch
>and recompile httpd before they can do so, and repeat this step
>each time they upgrade Apache.
I just wonder if i successfully realize this feature. Is it possible to
include the modification to the new release of Apache http server.
Any comments are greatly appreciated. Thanks a lot in advance!
br
frankie
_________________________________________________________________
与联机的朋友进行交流,请使用 Live Messenger;
http://get.live.com/messenger/overview
Re: questions related to compile!
Posted by 张 臻博 <la...@hotmail.com>.
>>>How can i include the source file that i made in the Apache server
>>> comiplation process, while the module is still built as a DSO by
>>> using apxs
>>
>>You would have to declare the structure in a header file, which you
>> #include in both your module source code and in the Apache source
>> file where you reference it. Then, when you configure httpd, you
>>can tell it where your header file lives by passing an environment
>> variable, like:
>>
>>CFLAGS="-I/path/to/your/module/source" ./configure ...
>
>I have checked the manual for configuration. It says:
>
>CFLAGS
> Set C compiler flags you want to use for compilation.
>CPPFLAGS
> Set C/C++ preprocessor flags, e.g. -Iincludedir if you have
>headers in a nonstandard directory includedir.
>
>So shall i use CPPFLAGS instead of CFLAGS? Actually i have tried
>both. Unfortunately, it seems in the apr_poll.h(where i include the
>header file), it still can not find the header file correctly. What
>is the problem....?
Here is part of the error information:
/bin/bash /p/work/Dec2007/zzhang/httpd-2.2.4/srclib/apr/libtool --silent
--mode=compile gcc -g -O2 -pthread -DHAVE_CONFIG_H -DLINUX=2 -D_REENTRANT
-D_GNU_SOURCE -D_LARGEFILE64_SOURCE
-I/p/work/Dec2007/zzhang/httpd-2.2.4/modules/dtn -I./include
-I/p/work/Dec2007/zzhang/httpd-2.2.4/srclib/apr/include/arch/unix
-I./include/arch/unix
-I/p/work/Dec2007/zzhang/httpd-2.2.4/srclib/apr/include -o
poll/unix/epoll.lo -c poll/unix/epoll.c && touch poll/unix/epoll.lo
In file included from ./include/apr_poll.h:30,
from
/p/work/Dec2007/zzhang/httpd-2.2.4/srclib/apr/include/arch/unix/apr_arch_poll_private.h:21,
from poll/unix/epoll.c:17:
/p/work/Dec2007/zzhang/httpd-2.2.4/modules/dtn/http_dtn.h:20:19: error:
httpd.h: No such file or directory
/p/work/Dec2007/zzhang/httpd-2.2.4/modules/dtn/http_dtn.h:21:25: error:
http_config.h: No such file or directory
/p/work/Dec2007/zzhang/httpd-2.2.4/modules/dtn/http_dtn.h:22:23: error:
http_core.h: No such file or directory
/p/work/Dec2007/zzhang/httpd-2.2.4/modules/dtn/http_dtn.h:23:22: error:
http_log.h: No such file or directory
/p/work/Dec2007/zzhang/httpd-2.2.4/modules/dtn/http_dtn.h:24:23: error:
http_main.h: No such file or directory
/p/work/Dec2007/zzhang/httpd-2.2.4/modules/dtn/http_dtn.h:25:27: error:
http_protocol.h: No such file or directory
/p/work/Dec2007/zzhang/httpd-2.2.4/modules/dtn/http_dtn.h:26:26: error:
http_request.h: No such file or directory
/p/work/Dec2007/zzhang/httpd-2.2.4/modules/dtn/http_dtn.h:27:25: error:
util_script.h: No such file or directory
/p/work/Dec2007/zzhang/httpd-2.2.4/modules/dtn/http_dtn.h:28:29: error:
http_connection.h: No such file or directory
It seems by using CPPFLAGS, the source directory
/p/work/Dec2007/zzhang/httpd-2.2.4/modules/dtn is scuccessfully in cluded
for compilation.
Now the error is that in the header file written by me. I used e.g.
#include "httpd.h"
#include "http_config.h" to include the Apache header file. However, the
files can not be found... Any idea aobut this?
thanks a lot
_________________________________________________________________
与联机的朋友进行交流,请使用 Live Messenger;
http://get.live.com/messenger/overview
Re: questions related to compile!
Posted by 张 臻博 <la...@hotmail.com>.
hello,
>>How can i include the source file that i made in the Apache server
>>comiplation process, while the module is still built as a DSO by
>>using apxs
>
>You would have to declare the structure in a header file, which you
>#include in both your module source code and in the Apache source
>file where you reference it. Then, when you configure httpd, you can
> tell it where your header file lives by passing an environment
>variable, like:
>
>CFLAGS="-I/path/to/your/module/source" ./configure ...
I have checked the manual for configuration. It says:
CFLAGS
Set C compiler flags you want to use for compilation.
CPPFLAGS
Set C/C++ preprocessor flags, e.g. -Iincludedir if you have headers in
a nonstandard directory includedir.
So shall i use CPPFLAGS instead of CFLAGS? Actually i have tried both.
Unfortunately, it seems in the apr_poll.h(where i include the header file),
it still can not find the header file correctly. What is the problem....?
Thanks a lot
br
frankie
_________________________________________________________________
享用世界上最大的电子邮件系统― MSN Hotmail。 http://www.hotmail.com
Re: questions related to compile!
Posted by Sander Temme <sc...@apache.org>.
On Feb 6, 2007, at 11:53 AM, 张 臻博 wrote:
> How can i include the source file that i made in the Apache server
> comiplation process, while the module is still built as a DSO by
> using apxs
You would have to declare the structure in a header file, which you
#include in both your module source code and in the Apache source
file where you reference it. Then, when you configure httpd, you can
tell it where your header file lives by passing an environment
variable, like:
CFLAGS="-I/path/to/your/module/source" ./configure ...
It is of course entirely up to you how you design your module and its
interaction with the core, and we cannot make any assumptions about
your particular requirements. However, you must realize that
modifying the httpd core ties your module completely to that modified
version of Apache: anyone who wants to use it must patch and
recompile httpd before they can do so, and repeat this step each time
they upgrade Apache.
The module API was designed to allow modules a considerable amount of
flexibility, and provides opportunities to store both long-lived
configuration data and arbitrary data per request, per connection or
attached to a memory pool. The various callback hooks provide
modules with opportunity to manipulate this data, along with the
request information, at many points during the handling cycle. You
may refer to modules/experimental/mod_example.c in the httpd trunk
for more information.
Regards,
S.
--
sctemme@apache.org http://www.temme.net/sander/
PGP FP: 51B4 8727 466A 0BC3 69F4 B7B8 B2BE BC40 1529 24AF