When starting nginx with mutil-processes, secondary worker may be spawned before primary worker completing initialization of fstack(dpdk), so errors occurred, for one, in kni.
1. `#define SOCK_FSTACK 0x1000`
2. when we want to create socket by fstack, we code like this :
`s = ngx_socket(domain, type | SOCK_FSTACK , protocol);`
1. Add a new directive proxy_kernel_network_stack :
Syntax: proxy_kernel_network_stack on | off;
Default: proxy_kernel_network_stack off;
Context: http, stream, mail, server
This directive is available only when NGX_HAVE_FF_STACK is defined.
Determines whether proxy should go throught kernel network stack or fstack.
2.Update F-Stack_Nginx_APP_Guide.md
1. Nginx based on fstack delays setting up server on fstack until ngx_worker_process_init. ngx_configure_listening_sockets should as well.
2. FStack does not support IP_PKTINFO
When nginx is configured like this:
```
server {
listen 8000;
kernel_network_stack on;
location / {
proxy_pass http://127.0.0.1:8080/;
}
}
```
nginx will crash, becasue kernel network stack is handled in a single thread, but we have hijacked all the socket apis, it causes that all apis enter to f-stack's path which is in main thread.
e.g. unix socket, ipc (with APP on kernel network stack), packet from kernel network stack.
1. Add a new directive kernel_network_stack :
Syntax: kernel_network_stack on | off;
Default: kernel_network_stack off;
Context: http, server
This directive is available only when NGX_HAVE_FF_STACK is defined.
Determines whether server should run on kernel network stack or fstack.
2. Use a simpler and more effective solution to discriminate fstack fd(file descriptor, only socket for now) from kernel fd.
In the redis, the gettimeofday uses too much CPU, even using the
vdso. This patch is useful to avoid wasting CPU cycles and
improve the performance.
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
For using the redis, we should allow users to configure
theirs configure file. Now fstack uses the options as below:
—-conf config.ini --proc-type= --proc-id=
And we should skip 4 args(including program name arg), not 3.
Use the redis-config-file:
bin/redis-server --conf config.ini \
--proc-type=primary --proc-id=0 redis-3.2.8/redis.conf
Signed-off-by: Tonghao Zhang <xiangxia.m.yue@gmail.com>
Since f-stack run with polling mode, nginx will call gettimeofday every loop, and cost a lot.
With this commit, f-stack will update current timespec periodically in
ff_hardclock_job. And ff_gettimeofday will get this value.
In nginx, hijack gettimeofday to call ff_gettimeofday.
When use nginx as a proxy, nginx error logs always print 'readv() failed
(9: Bad file descriptor) while reading upstream'.
In previous commit: 10c5711ed2, i removed
`readv`, caused this issue.
Since ngx_ff_module.c was derived from nginx_ofp's ngx_ofp_module.c, but
according to #42, nginx_ofp's ngx_ofp_module.c may be derived from
opendp/dpdk-nginx's ans_module.c and nginx_ofp didn't have a license, so
add opendp/dpdk-nginx's license.
The newer version of libcrypto will invoke read and close function when
dl_init, the real address of read/close function can’t be determined in
compilation phase and libcrypto will seek read/close symbol in ELF
files and other libraries. However nginx_fstack redefined these two
functions, this causes these symbols to be found in nginx_fstack. But the real read/close function is NULL before ff_mod_init, this leads to crash.
Changes:
1.if real_close is NULL, assign it with the address of close function in Glibc.
2.remove unnecessary read/readv/write.