catalinux / Conn (public) (License: LGPLv2) (since 2016-03-01) (hash sha1)
Net library for easy building ipv4/ipv6 network daemons/clients
List of commits:
Subject Hash Author Date (UTC)
Build fixes e7521468199d4da53461fb0c1ffa08e1913c1e9f Catalin(ux) M. BOIE 2015-04-24 19:18:42
Checkpoint before switching to processes not threads de43b387557dde215ab1210838d396e7e7b22c4f Catalin(ux) M. BOIE 2015-01-14 04:13:00
Wpools work now\! f875d6bea1777c3a290bf9bb1aa047f26c935a63 Catalin(ux) M. BOIE 2013-11-13 20:51:13
WIP 1d246f2130d4acf8c267e82051b250a623da6870 Catalin(ux) M. BOIE 2013-10-16 19:57:04
WIP 6387026db3ce7983e610887565a282f4124d4092 Catalin(ux) M. BOIE 2013-10-14 20:06:49
WIP 15f063f9d34d3f7b7ae9d9e83f59b4077515122b Catalin(ux) M. BOIE 2010-09-30 22:01:30
Switch licence to LGPLv3+; Do not stupidly close master socket. d3b1c4ccd591627e7faa0eeaaa3b2bc1ee20709e Catalin(ux) M. BOIE 2013-08-14 04:09:36
Duilder fixes. Removed -O0. Fixed spec file. d8a03dced52e918b6f66a05dfd64a3c75c07c91b Catalin(ux) M. BOIE 2011-12-14 09:12:55
Fixed a stupid logging bug (invalid number of parameters). e7d4c38d0130a142ac6c409c63d63201d2af08e2 Catalin(ux) M. BOIE 2010-12-22 16:46:47
Ignore all Changelog files. fa45b63d3db958228f44bcb3d6431d60f94d1147 Catalin(ux) M. BOIE 2010-12-22 16:46:16
Added mailmap file. a57dcfd6bdf6c8c86161cf7ce3fff942a714a2b9 Catalin(ux) M. BOIE 2010-12-22 16:46:04
WIP a69db41578de7ded49d656b7ea7cfae76c6695d9 Catalin(ux) M. BOIE 2010-09-30 22:01:30
Be more verbose in try_expand_buf and error out connection when cannot expand. e95ac8d7e5015958d3594862c6183b63bab80d4a Catalin(ux) M. BOIE 2010-09-30 20:58:08
Ignore xbind1 compiled example. 089b68cf9fc5c16ee7d8136b28a52ec4dd139c78 Catalin(ux) M. BOIE 2010-08-23 19:42:01
Removed direct access to Conn structure in s.c example. f6215273602571ef2c98479bdba930ebe312cbc9 Catalin(ux) M. BOIE 2010-08-23 19:38:33
Bumped the version to 1.0.32. f158fca2cf9f3285ae761cd4ce30b01911b84385 Catalin(ux) M. BOIE 2010-06-23 21:30:47
The cache for epoll_ctl, has to take also the slot in consideration. ed378c16927c707feee481b2cd0ea7fbdf257d9d Catalin(ux) M. BOIE 2010-06-09 19:18:03
After calling getsockname, set cache as clean. 199f0fd96b064fd1e63f5773b1e7ab58e7d91303 Catalin(ux) M. BOIE 2010-06-08 18:30:20
Do not try to call getsockname if connection is not opened. e9853b5b5a01df3c5e07f6fe4607a68fd7181b39 Catalin(ux) M. BOIE 2010-06-08 18:28:49
Supports kernels below 2.6.9 (epoll_ctl). 97919a022fae39bdefc3f7e4c50526fb473dfd34 Catalin(ux) M. BOIE 2010-06-08 18:06:35
Commit e7521468199d4da53461fb0c1ffa08e1913c1e9f - Build fixes
After adding the new flags, some warnings were converted to erros
making build to fail.
Author: Catalin(ux) M. BOIE
Author date (UTC): 2015-04-24 19:18
Committer name: Catalin(ux) M. BOIE
Committer date (UTC): 2015-04-24 19:18
Parent(s): de43b387557dde215ab1210838d396e7e7b22c4f
Signing key:
Tree: a906c9ad5f2d17b91dfd33df602285198802d702
File Lines added Lines deleted
Conn.c 10 10
Conn.h 2 0
Makefile.in 2 2
TODO 10 0
duilder 24 13
duilder.conf 3 2
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 Conn.h changed (mode: 100644) (index 594181f..5bb590b)
11 11 struct Conn; struct Conn;
12 12 struct Conn_wpool; struct Conn_wpool;
13 13 struct Conn_split; struct Conn_split;
14 struct Conn_ws;
14 15
15 16 /* Parameters */ /* Parameters */
16 17 enum CONN_PARA { enum CONN_PARA {
 
... ... extern int Conn_band(struct Conn *C, const unsigned int width,
132 133 extern int Conn_poll(const int timeout); extern int Conn_poll(const int timeout);
133 134
134 135 /* web server */ /* web server */
136 void Conn_ws_free(struct Conn_ws *ws);
135 137 int Conn_ws_create(struct Conn *C); int Conn_ws_create(struct Conn *C);
136 138 int Conn_ws_script(struct Conn *C, const char *url, int Conn_ws_script(struct Conn *C, const char *url,
137 139 void(*cb)(struct Conn *C)); void(*cb)(struct Conn *C));
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
File duilder.conf changed (mode: 100644) (index 809c9f3..3ed2467)
1 1 PRJ="Conn" PRJ="Conn"
2 VER="1.0.33"
2 VER="1.0.34"
3 3 REV="1" REV="1"
4 4 EXCLUDE="" EXCLUDE=""
5 5 EXPORT_PATH="/data/www/umbrella/kernel/us/Conn" EXPORT_PATH="/data/www/umbrella/kernel/us/Conn"
6 6 EXPORT_GIT="0" EXPORT_GIT="0"
7 GIT_PUSH="1"
7 GIT_PUSH="0"
8 8 GIT_CHANGELOG="1" GIT_CHANGELOG="1"
9 9 BUILD_SRPM="1" BUILD_SRPM="1"
10 10 SRPM_DEST="../dinorepo/fedora/SRPMS" SRPM_DEST="../dinorepo/fedora/SRPMS"
 
... ... BUILD_DEB="1"
15 15 CONFIG_H="Conn_config.h" CONFIG_H="Conn_config.h"
16 16
17 17 RELEASE_SCRIPT="./duilder_release" RELEASE_SCRIPT="./duilder_release"
18 RELEASE_SCRIPT="/usr/local/bin/duilder_release"
Hints:
Before first commit, do not forget to setup your git environment:
git config --global user.name "your_name_here"
git config --global user.email "your@email_here"

Clone this repository using HTTP(S):
git clone https://rocketgit.com/user/catalinux/Conn

Clone this repository using ssh (do not forget to upload a key first):
git clone ssh://rocketgit@ssh.rocketgit.com/user/catalinux/Conn

Clone this repository using git:
git clone git://git.rocketgit.com/user/catalinux/Conn

You are allowed to anonymously push to this repository.
This means that your pushed commits will automatically be transformed into a merge request:
... clone the repository ...
... make some changes and some commits ...
git push origin main