File Conn.c changed (mode: 100644) (index 4a588a1..f1e72cb) |
... |
... |
static struct Conn_cbs Conn_default_cbs = |
309 |
309 |
__cold void Log(const unsigned short level, char *format, ...) |
__cold void Log(const unsigned short level, char *format, ...) |
310 |
310 |
{ |
{ |
311 |
311 |
va_list ap; |
va_list ap; |
312 |
|
int len; |
|
|
312 |
|
unsigned int len; |
313 |
313 |
char line[512]; |
char line[512]; |
314 |
314 |
|
|
315 |
315 |
if (likely(level > Conn_debug_level)) |
if (likely(level > Conn_debug_level)) |
|
... |
... |
static inline int Conn_add_obj(int epoll_fd, struct Conn *C, |
528 |
528 |
Log(1, "%s Could not add fd %d to epoll_fd %d, events 0x%x (%s)!\n", |
Log(1, "%s Could not add fd %d to epoll_fd %d, events 0x%x (%s)!\n", |
529 |
529 |
__func__, C->fd, epoll_fd, events, strerror(errno)); |
__func__, C->fd, epoll_fd, events, strerror(errno)); |
530 |
530 |
C->xerrno = errno; |
C->xerrno = errno; |
531 |
|
snprintf(Conn_error, sizeof(Conn_error), |
|
|
531 |
|
snprintf(Conn_error, sizeof(Conn_error), "%s", |
532 |
532 |
strerror(C->xerrno)); |
strerror(C->xerrno)); |
533 |
533 |
return C->xerrno; |
return C->xerrno; |
534 |
534 |
} |
} |
|
... |
... |
static inline int Conn_change_obj(int epoll_fd, struct Conn *C, |
552 |
552 |
Log(1, "%s Could not change fd %d to epoll_fd %d, events 0x%x (%s)!\n", |
Log(1, "%s Could not change fd %d to epoll_fd %d, events 0x%x (%s)!\n", |
553 |
553 |
__func__, C->fd, epoll_fd, events, strerror(errno)); |
__func__, C->fd, epoll_fd, events, strerror(errno)); |
554 |
554 |
C->xerrno = errno; |
C->xerrno = errno; |
555 |
|
snprintf(Conn_error, sizeof(Conn_error), |
|
|
555 |
|
snprintf(Conn_error, sizeof(Conn_error), "%s", |
556 |
556 |
strerror(C->xerrno)); |
strerror(C->xerrno)); |
557 |
557 |
return C->xerrno; |
return C->xerrno; |
558 |
558 |
} |
} |
|
... |
... |
static int Conn_alphanum(const char *s) |
816 |
816 |
/* |
/* |
817 |
817 |
* Gets a reference to a wpool structure |
* Gets a reference to a wpool structure |
818 |
818 |
*/ |
*/ |
819 |
|
void Conn_wpool_get(struct Conn_wpool *wp) |
|
|
819 |
|
static void Conn_wpool_get(struct Conn_wpool *wp) |
820 |
820 |
{ |
{ |
821 |
821 |
wp->refs++; |
wp->refs++; |
822 |
822 |
} |
} |
|
... |
... |
void Conn_wpool_get(struct Conn_wpool *wp) |
824 |
824 |
/* |
/* |
825 |
825 |
* Decrements usage |
* Decrements usage |
826 |
826 |
*/ |
*/ |
827 |
|
void Conn_wpool_put(struct Conn_wpool *wp) |
|
|
827 |
|
static void Conn_wpool_put(struct Conn_wpool *wp) |
828 |
828 |
{ |
{ |
829 |
829 |
wp->refs--; |
wp->refs--; |
830 |
830 |
if (wp->refs == 0) |
if (wp->refs == 0) |
|
... |
... |
long long Conn_time_diff(const struct timeval *t1, const struct timeval *t2) |
1169 |
1169 |
/* |
/* |
1170 |
1170 |
* Returns string representation of errno code |
* Returns string representation of errno code |
1171 |
1171 |
*/ |
*/ |
1172 |
|
char *Conn_errno(const struct Conn *C) |
|
|
1172 |
|
static char *Conn_errno(const struct Conn *C) |
1173 |
1173 |
{ |
{ |
1174 |
1174 |
static char buf[256]; |
static char buf[256]; |
1175 |
1175 |
char *is; |
char *is; |
|
... |
... |
__cold static int pool_grow(struct Conn_pool *x, const unsigned int increment) |
2363 |
2363 |
/* |
/* |
2364 |
2364 |
* This is called after allocation to init some fields. |
* This is called after allocation to init some fields. |
2365 |
2365 |
*/ |
*/ |
2366 |
|
__hot struct Conn *Conn_alloc_prepare(struct Conn *C) |
|
|
2366 |
|
__hot static struct Conn *Conn_alloc_prepare(struct Conn *C) |
2367 |
2367 |
{ |
{ |
2368 |
2368 |
void *p; |
void *p; |
2369 |
2369 |
|
|
|
... |
... |
__hot struct Conn *Conn_alloc(void) |
2488 |
2488 |
/* |
/* |
2489 |
2489 |
* Allocates a Conn structure, worker version |
* Allocates a Conn structure, worker version |
2490 |
2490 |
*/ |
*/ |
2491 |
|
__hot struct Conn *Conn_alloc_worker(struct Conn_wpool_worker *w) |
|
|
2491 |
|
__hot static struct Conn *Conn_alloc_worker(struct Conn_wpool_worker *w) |
2492 |
2492 |
{ |
{ |
2493 |
2493 |
struct Conn *C; |
struct Conn *C; |
2494 |
2494 |
int r; |
int r; |
|
... |
... |
int Conn_commit(struct Conn *C) |
3292 |
3292 |
ret = inet_pton(AF_INET, C->bind_addr, &bind_sa.sin_addr); |
ret = inet_pton(AF_INET, C->bind_addr, &bind_sa.sin_addr); |
3293 |
3293 |
if (ret < 0) { |
if (ret < 0) { |
3294 |
3294 |
snprintf(Conn_error, sizeof(Conn_error), |
snprintf(Conn_error, sizeof(Conn_error), |
3295 |
|
"inet_pton(%s) failed", C->bind_addr); |
|
|
3295 |
|
"inet_pton(%s) failed", C->bind_addr); |
3296 |
3296 |
return -1; |
return -1; |
3297 |
3297 |
} |
} |
3298 |
3298 |
bind_sa.sin_port = htons(C->bind_port); |
bind_sa.sin_port = htons(C->bind_port); |
|
... |
... |
int Conn_poll(const int timeout) |
3783 |
3783 |
/* |
/* |
3784 |
3784 |
* Dumps some statistics |
* Dumps some statistics |
3785 |
3785 |
*/ |
*/ |
3786 |
|
void Conn_stats(void) |
|
|
3786 |
|
static void Conn_stats(void) |
3787 |
3787 |
{ |
{ |
3788 |
3788 |
} |
} |
3789 |
3789 |
|
|
File Makefile.in changed (mode: 100644) (index 00b7e4f..9d18f20) |
... |
... |
export LIBS += -lpthread |
4 |
4 |
export OBJS += Conn.o |
export OBJS += Conn.o |
5 |
5 |
|
|
6 |
6 |
export CFLAGS += -Wall -Wextra -pipe -O3 -g -ggdb |
export CFLAGS += -Wall -Wextra -pipe -O3 -g -ggdb |
7 |
|
export CFLAGS += -Wconversion -Wcast-align -Wformat=2 -Wformat-security -fno-common |
|
|
7 |
|
export CFLAGS += -Wcast-align -Wformat=2 -Wformat-security -fno-common |
8 |
8 |
export CFLAGS += -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes |
export CFLAGS += -Wmissing-prototypes -Wmissing-declarations -Wstrict-prototypes |
9 |
9 |
export CFLAGS += -Wstrict-overflow -Wtrampolines -flto |
export CFLAGS += -Wstrict-overflow -Wtrampolines -flto |
10 |
10 |
export CFLAGS += -fstack-protector-all |
export CFLAGS += -fstack-protector-all |
11 |
11 |
export CFLAGS += -D _FORTIFY_SOURCES=2 |
export CFLAGS += -D _FORTIFY_SOURCES=2 |
12 |
12 |
export CFLAGS += -fstack-reuse=all -fbounds-check |
export CFLAGS += -fstack-reuse=all -fbounds-check |
13 |
13 |
export CFLAGS += -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-O1 |
export CFLAGS += -Wl,-z,noexecstack -Wl,-z,now -Wl,-z,relro -Wl,-O1 |
14 |
|
|
|
|
14 |
|
# TODO export CFLAGS += -Wconversion |
15 |
15 |
|
|
16 |
16 |
.PHONY: all |
.PHONY: all |
17 |
17 |
all: libConn.so.@VER@ |
all: libConn.so.@VER@ |
File TODO changed (mode: 100644) (index 2ba4b60..98bc469) |
|
1 |
|
[ ] When alocating a poll of Conns, check the alignment! |
1 |
2 |
[ ] http://thread.gmane.org/gmane.linux.network/337836 - SO_INCOMING_CPU |
[ ] http://thread.gmane.org/gmane.linux.network/337836 - SO_INCOMING_CPU |
2 |
3 |
|
|
3 |
4 |
[ ] Scenario: raspundem la un request, vedem ca nu mai avem nimic de trimis, |
[ ] Scenario: raspundem la un request, vedem ca nu mai avem nimic de trimis, |
|
6 |
7 |
[ ] De facut o schema cu starile prin care trece o conexiune, suspectez |
[ ] De facut o schema cu starile prin care trece o conexiune, suspectez |
7 |
8 |
ca atunci cind obuf e 0, nu fac shutdown in loc de close. |
ca atunci cind obuf e 0, nu fac shutdown in loc de close. |
8 |
9 |
[ ] La http/1.1, default e sa nu inchida conexiunea. |
[ ] La http/1.1, default e sa nu inchida conexiunea. |
|
10 |
|
[ ] SO_INCOMING_CPU http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=2c8c56e15df3d4c2af3d656e44feb18789f75837 |
|
11 |
|
[ ] Check the new batch mode of epoll |
|
12 |
|
[ ] Use SO_REUSEPORT for accept(): |
|
13 |
|
!!! http://lists.dragonflybsd.org/pipermail/users/2013-July/053632.html |
|
14 |
|
!!! https://github.com/monkey/monkey/commit/d1da249a0b5e8f5765ea8031919fb32e93c57cb8 |
|
15 |
|
[ ] Use defer accept! |
|
16 |
|
[ ] |
9 |
17 |
|
|
10 |
18 |
== Devel point == |
== Devel point == |
|
19 |
|
[ ] I think that I must switch back to processes. Too much overhead for threads. |
|
20 |
|
And I do not know if I gain something by using threads. |
11 |
21 |
[ ] Now I am working on simple web requests. |
[ ] Now I am working on simple web requests. |
12 |
22 |
Static (/) and dynamic (/cgi?a=1). |
Static (/) and dynamic (/cgi?a=1). |
13 |
23 |
[ ] We must send "HTTP/x.x code message" respecting incoming request. |
[ ] We must send "HTTP/x.x code message" respecting incoming request. |
File duilder changed (mode: 100755) (index a6e2825..87c4881) |
... |
... |
function duilder_docs() |
27 |
27 |
fi |
fi |
28 |
28 |
|
|
29 |
29 |
echo "[*] Copying docs to [${EXPORT_PATH}]..." |
echo "[*] Copying docs to [${EXPORT_PATH}]..." |
30 |
|
for f in README License LICENSE Changelog Changelog-last TODO FAQ INSTALL; do |
|
|
30 |
|
for f in README License LICENSE Changelog Changelog-last TODO FAQ INSTALL AUTHORS; do |
31 |
31 |
if [ -r "${f}" ]; then |
if [ -r "${f}" ]; then |
32 |
32 |
cp -vp "${f}" "${EXPORT_PATH}/" |
cp -vp "${f}" "${EXPORT_PATH}/" |
33 |
33 |
fi |
fi |
|
... |
... |
function duilder_tar() |
217 |
217 |
ADD_EXCLUDE="" |
ADD_EXCLUDE="" |
218 |
218 |
if [ ! -z "${EXCLUDE}" ]; then |
if [ ! -z "${EXCLUDE}" ]; then |
219 |
219 |
ADD_EXCLUDE="--exclude-from ${P}/${EXCLUDE}" |
ADD_EXCLUDE="--exclude-from ${P}/${EXCLUDE}" |
|
220 |
|
echo "[*] ADD_EXCLUDE=${ADD_EXCLUDE}" |
220 |
221 |
fi |
fi |
221 |
222 |
|
|
222 |
223 |
(cd .. \ |
(cd .. \ |
|
... |
... |
if [ -z "${REV}" ]; then |
274 |
275 |
fi |
fi |
275 |
276 |
|
|
276 |
277 |
# export variables - just in case a script cares |
# export variables - just in case a script cares |
277 |
|
export PRJ VER REV EXPORT_PATH EXPORT_GIT GIT_PUSH GIT_DEST SRPM_DEST LICENSE |
|
|
278 |
|
export PRJ VER REV SHORT_DESCRIPTION EXPORT_PATH EXPORT_GIT GIT_PUSH GIT_DEST SRPM_DEST LICENSE |
278 |
279 |
|
|
279 |
280 |
|
|
280 |
281 |
# Multiplexer |
# Multiplexer |
|
... |
... |
USR_SHARE_DOC="/usr/share/doc/${PRJ}-${VER}" |
326 |
327 |
SBIN="/usr/sbin" |
SBIN="/usr/sbin" |
327 |
328 |
VAR="/var" |
VAR="/var" |
328 |
329 |
VAR_LIB="/var/lib" |
VAR_LIB="/var/lib" |
|
330 |
|
MAN="/usr/share/man" |
329 |
331 |
|
|
330 |
332 |
while [ "${1}" != "" ]; do |
while [ "${1}" != "" ]; do |
331 |
|
VAR="`echo ${1} | cut -d'=' -f1`" |
|
332 |
|
VAL="`echo ${1} | cut -d'=' -f2`" |
|
333 |
|
case ${VAR} in |
|
|
333 |
|
xVAR="`echo ${1} | cut -d'=' -f1`" |
|
334 |
|
xVAL="`echo ${1} | cut -d'=' -f2`" |
|
335 |
|
case ${xVAR} in |
334 |
336 |
--sysconfdir) |
--sysconfdir) |
335 |
|
ETC="${VAL}" |
|
|
337 |
|
ETC="${xVAL}" |
336 |
338 |
;; |
;; |
337 |
339 |
--bindir) |
--bindir) |
338 |
|
USR_BIN="${VAL}" |
|
|
340 |
|
USR_BIN="${xVAL}" |
339 |
341 |
;; |
;; |
340 |
342 |
--sbindir) |
--sbindir) |
341 |
|
USR_SBIN="${VAL}" |
|
|
343 |
|
USR_SBIN="${xVAL}" |
342 |
344 |
;; |
;; |
343 |
345 |
--includedir) |
--includedir) |
344 |
|
USR_INCLUDE="${VAL}" |
|
|
346 |
|
USR_INCLUDE="${xVAL}" |
345 |
347 |
;; |
;; |
346 |
348 |
--libdir) |
--libdir) |
347 |
|
USR_LIB="${VAL}" |
|
|
349 |
|
USR_LIB="${xVAL}" |
348 |
350 |
;; |
;; |
349 |
351 |
--localstatedir) |
--localstatedir) |
350 |
|
VAR="${VAL}" |
|
|
352 |
|
VAR="${xVAL}" |
351 |
353 |
;; |
;; |
352 |
354 |
--sharedstatedir) |
--sharedstatedir) |
353 |
|
VAR_LIB="${VAL}" |
|
|
355 |
|
VAR_LIB="${xVAL}" |
354 |
356 |
;; |
;; |
355 |
357 |
--datadir) |
--datadir) |
356 |
|
USR_SHARE="${VAL}" |
|
|
358 |
|
USR_SHARE="${xVAL}" |
|
359 |
|
;; |
|
360 |
|
--mandir) |
|
361 |
|
MAN="${xVAL}" |
357 |
362 |
;; |
;; |
358 |
363 |
esac |
esac |
359 |
364 |
shift |
shift |
|
... |
... |
done |
363 |
368 |
VAR_LOG="${VAR}/log" |
VAR_LOG="${VAR}/log" |
364 |
369 |
VAR_RUN="${VAR}/run" |
VAR_RUN="${VAR}/run" |
365 |
370 |
|
|
|
371 |
|
for i in ETC BIN USR_BIN USR_SBIN USR_INCLUDE USR_LIB USR_SHARE USR_SHARE_DOC SBIN VAR VAR_LIB MAN VAR_LOG VAR_RUN; do |
|
372 |
|
eval value=\$$i |
|
373 |
|
echo "[*] Var ${i}=${value}" |
|
374 |
|
done |
366 |
375 |
|
|
367 |
376 |
# Truncate future sed file |
# Truncate future sed file |
368 |
377 |
> tmp.sed |
> tmp.sed |
|
... |
... |
echo "s#@USR_INC@#${USR_INCLUDE}#g" >> tmp.sed |
471 |
480 |
echo "s#@USR_LIB@#${USR_LIB}#g" >> tmp.sed |
echo "s#@USR_LIB@#${USR_LIB}#g" >> tmp.sed |
472 |
481 |
echo "s#@USR_SHARE@#${USR_SHARE}#g" >> tmp.sed |
echo "s#@USR_SHARE@#${USR_SHARE}#g" >> tmp.sed |
473 |
482 |
echo "s#@USR_SHARE_DOC@#${USR_SHARE_DOC}#g" >> tmp.sed |
echo "s#@USR_SHARE_DOC@#${USR_SHARE_DOC}#g" >> tmp.sed |
|
483 |
|
echo "s#@MAN@#${MAN}#g" >> tmp.sed |
474 |
484 |
# Export stuff |
# Export stuff |
475 |
485 |
echo "s#@EXPORT_PATH@#${EXPORT_PATH}#g" >> tmp.sed |
echo "s#@EXPORT_PATH@#${EXPORT_PATH}#g" >> tmp.sed |
476 |
486 |
|
|
|
... |
... |
if [ -r Makefile.in ]; then |
500 |
510 |
echo "export I_VAR_LIB := \$(DESTDIR)${VAR_LIB}" >> Makefile |
echo "export I_VAR_LIB := \$(DESTDIR)${VAR_LIB}" >> Makefile |
501 |
511 |
echo "export I_VAR_LOG := \$(DESTDIR)${VAR_LOG}" >> Makefile |
echo "export I_VAR_LOG := \$(DESTDIR)${VAR_LOG}" >> Makefile |
502 |
512 |
echo "export I_VAR_RUN := \$(DESTDIR)${VAR_RUN}" >> Makefile |
echo "export I_VAR_RUN := \$(DESTDIR)${VAR_RUN}" >> Makefile |
|
513 |
|
echo "export I_MAN := \$(DESTDIR)${MAN}" >> Makefile |
503 |
514 |
echo >> Makefile |
echo >> Makefile |
504 |
515 |
echo "# DB stuff" >> Makefile |
echo "# DB stuff" >> Makefile |
505 |
516 |
echo "export DB_SUPPORT := ${DB_SUPPORT}" >> Makefile |
echo "export DB_SUPPORT := ${DB_SUPPORT}" >> Makefile |