# -*- Makefile -*- # # This is a make+ file. Make+ is a set of scripts which enhance GNU # make and let you build RPMs, and other package types with just one # control file. To build this package you will need to download make+ # from this site: http://www.annexia.org/freeware/makeplus/ PACKAGE := pthrlib VERSION_MAJOR := 3 VERSION_MINOR := 3.1 VERSION := $(VERSION_MAJOR).$(VERSION_MINOR) SUMMARY := small, fast, efficient server library for C COPYRIGHT := GNU LGPL AUTHOR := Richard W.M. Jones define DESCRIPTION pthrlib is a library for writing small, fast and efficient servers in C. It offers a list of advanced features. This library has been used to write a very tiny and fast web server called rws and a closed source chat server. All functions are documented in manual pages, and example servers are included. endef RPM_REQUIRES := c2lib >= 1.4.0, postgresql-devel >= 7.1 RPM_GROUP := Development/Libraries CFLAGS += -Wall -Werror -g -O2 -I$(includedir)/c2lib ifeq (1,$(HAVE_PG_CONFIG)) CFLAGS += -I$(shell pg_config --includedir) endif ifneq ($(shell uname), SunOS) # Avoid a warning about reordering system include paths. CFLAGS += $(shell pcre-config --cflags) endif ifeq (1,$(HAVE_PG_CONFIG)) LIBS += -L$(shell pg_config --libdir) -lpq endif LIBS += $(shell pcre-config --libs) -lm OBJS := src/pthr_cgi.o src/pthr_context.o src/pthr_dbi.o \ src/pthr_ftpc.o src/pthr_http.o src/pthr_iolib.o \ src/pthr_listener.o src/pthr_mutex.o \ src/pthr_pseudothread.o src/pthr_reactor.o \ src/pthr_rwlock.o src/pthr_server.o src/pthr_stack.o \ src/pthr_wait_queue.o LOBJS := $(OBJS:.o=.lo) HEADERS := $(srcdir)/src/pthr_cgi.h $(srcdir)/src/pthr_context.h \ $(srcdir)/src/pthr_dbi.h $(srcdir)/src/pthr_ftpc.h \ $(srcdir)/src/pthr_http.h $(srcdir)/src/pthr_iolib.h \ $(srcdir)/src/pthr_listener.h $(srcdir)/src/pthr_mutex.h \ $(srcdir)/src/pthr_pseudothread.h \ $(srcdir)/src/pthr_reactor.h \ $(srcdir)/src/pthr_rwlock.h $(srcdir)/src/pthr_server.h \ $(srcdir)/src/pthr_stack.h $(srcdir)/src/pthr_wait_queue.h all: build configure: @pg_config --version || \ ( echo "PostgreSQL must be installed - make sure PATH" \ "contains pg bin directory"; exit 1 ) $(MP_CONFIGURE_START) $(MP_REQUIRE_LIB) pmap c2lib $(MP_CHECK_PROG) pg_config $(MP_CHECK_LIB) PQconnectStart pq $(MP_CHECK_HEADERS) alloca.h arpa/inet.h assert.h \ ctype.h dirent.h errno.h \ execinfo.h fcntl.h grp.h libpq-fe.h netdb.h \ netinet/in.h netinet/ip.h netinet/ip_icmp.h postgresql/libpq-fe.h \ pwd.h setjmp.h signal.h string.h syslog.h sys/mman.h sys/poll.h \ sys/socket.h sys/stat.h sys/syslimits.h sys/time.h sys/types.h \ sys/uio.h sys/wait.h \ time.h ucontext.h unistd.h $(MP_CHECK_FUNCS) backtrace getenv gettimeofday gmtime putenv setenv \ socket strftime syslog time unsetenv PQescapeString $(srcdir)/conf/test_setcontext.sh $(MP_CONFIGURE_END) build: static dynamic examples/pthr_eg1_echo examples/pthr_eg2_server \ manpages syms # Build the static library. static: src/libpthrlib.a src/libpthrlib.a: $(OBJS) $(MP_LINK_STATIC) $@ $^ # Build the dynamic library. dynamic: src/libpthrlib.so src/libpthrlib.so: $(LOBJS) $(MP_LINK_DYNAMIC) $@ $^ $(LIBS) # Build object files. src/%.o: src/%.c $(CC) $(CFLAGS) -I../src -c $< -o $@ # Build dynamic object files. src/%.lo: src/%.c $(CC) $(CFLAGS) -fPIC -I../src -c $< -o $@ # Build the example programs. examples/pthr_eg1_echo: examples/pthr_eg1_echo.o examples/pthr_eg1_echo_main.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) examples/pthr_eg2_server: examples/pthr_eg2_server.o \ examples/pthr_eg2_server_main.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) # Build object files. examples/%.o: examples/%.c $(CC) $(CFLAGS) -I../src -c $< -o $@ # Build the manual pages. manpages: $(srcdir)/src/*.h if cdoc; then \ rm -f *.3; \ cdoc \ --author '$(AUTHOR)' \ --license '$(COPYRIGHT)' \ --version '$(PACKAGE)-$(VERSION)' \ $^; \ fi # Build the symbols table. syms: src/libpthrlib.syms src/libpthrlib.syms: src/libpthrlib.so nm $< | sort | grep -i '^[0-9a-f]' | awk '{print $$1 " " $$3}' > $@ test: src/test_context src/test_reactor src/test_pseudothread src/test_select \ src/test_bigstack src/test_except1 src/test_except2 src/test_except3 \ src/test_mutex src/test_rwlock src/test_dbi LD_LIBRARY_PATH=src:$(LD_LIBRARY_PATH) $(MP_RUN_TESTS) $^ src/test_context: src/test_context.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) src/test_reactor: src/test_reactor.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) src/test_pseudothread: src/test_pseudothread.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) src/test_select: src/test_select.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) src/test_bigstack: src/test_bigstack.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) src/test_except1: src/test_except1.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) src/test_except2: src/test_except2.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) src/test_except3: src/test_except3.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) src/test_mutex: src/test_mutex.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) src/test_rwlock: src/test_rwlock.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) src/test_dbi: src/test_dbi.o $(CC) $(CFLAGS) $^ -o $@ -Lsrc -lpthrlib $(LIBS) install: install -d $(DESTDIR)$(libdir) install -d $(DESTDIR)$(includedir) install -d $(DESTDIR)$(man3dir) install -d $(DESTDIR)$(datadir)/rws/symtabs/ install -d $(DESTDIR)$(bindir) $(MP_INSTALL_STATIC_LIB) src/libpthrlib.a $(MP_INSTALL_DYNAMIC_LIB) src/libpthrlib.so install -m 0644 $(HEADERS) $(DESTDIR)$(includedir) install -m 0644 *.3 $(DESTDIR)$(man3dir) install -m 0644 src/*.syms $(DESTDIR)$(datadir)/rws/symtabs/ install -m 0755 examples/pthr_eg1_echo examples/pthr_eg2_server \ $(DESTDIR)$(bindir) define WEBSITE <% include page_header.msp %>

$(PACKAGE) - $(SUMMARY)

pthrlib is a library for writing small, fast and efficient servers in C. It offers a list of advanced features (see below). This library has been used to write a very tiny and fast web server called rws and a closed source chat server. All functions are documented in manual pages, and example servers are included.

It contains the following features:

There is extensive documentation and a tutorial here.

Download

File Format Contents
$(PACKAGE)-$(VERSION).tar.gz tar.gz Latest source distribution
$(PACKAGE)-$(VERSION)-1.i686.rpm i686 binary RPM Binary development libraries, header files, man pages for Red Hat Linux
$(PACKAGE)-$(VERSION)-1.src.rpm source RPM Source files for Red Hat Linux

This library requires c2lib. To rebuild the manual pages which come with the package, you will also need to download the cdoc program. Since 3.2.0, pthrlib requires the make+ build system.

Patches between versions ...

News

Sat Feb 1 2003: Updated README and INSTALL files. Updated Makefile+ to work with the new version of make+. Ported to FreeBSD 5.0. Added connection pooling to pthr_dbi library. NB: The RPMs were built on Debian and may not work on Red Hat Linux.

Sat Feb 8 17:00:47 GMT 2003: Ported to Solaris, OpenBSD and FreeBSD (thanks to Jeremy Sowden and Richard Baker for help and equipment). Updated to work with gcc 3.2 (multi-line strings are now deprecated). Fixed for RH 7.3.

Sun Dec 8 13:44:32 GMT 2002: Major API change: current_pth contains the current thread. A lot of functions which took pth as a parameter now no longer need these parameter. Fixed io_popen to call _exit instead of exit so that the registered atexit functions aren't called incorrectly in the child process. Fixed pth_wait_writable, pth_wait_readable. Updated to use make+. Enabled debugging and optimisations. Fixes to compile on RH 7.3.

Mon Nov 25 09:31:37 GMT 2002: Added symbols file for full symbol resolution in monolith. Catch segfaults and dump a stack trace. Added mutex_nr_sleepers function.

Sun Nov 17 23:31:32 GMT 2002: Debian packages. Added MSP files. Added patches to enabled chunked encoding (thanks to Steve Atkins). Fixes to compile on RH 7.3. Support for DBI_TIMESTAMP, DBI_INTERVAL, DBI_INT_OR_NULL, DBI_CHAR, DBI_BOOL in the DBI library. Better handling of NULLs in the DBI library. Debugging for DBI.

Thu Nov 14 15:33:29 GMT 2002: Major checkpoint release for Monolith.

Sun Oct 20 14:46:46 BST 2002: Support for cookies. Get last serial number from an INSERT. DBI now correctly handles nulls in execute statements. Fixed elusive bugs in pth_wait_readable and pth_wait_writable which were causing monolith to crash. Optimisation to wait queues which also removes a crashing bug in monolith.

Tue Oct 15 23:40:42 BST 2002: Multiple bug fixes.

Sun Oct 13 18:47:41 BST 2002: Patch to disable test_dbi code if no DBI configured. Added pthr_server_default_address and pthr_server_address_option which allows the server to listen on a single interface instead of on INADDR_ANY. (Both patches thanks to Steve Atkins - steve at blighty com).

Sun Oct 13 12:55:08 BST 2002: Added a complete PostgreSQL database interface library, similar to the Perl DBI. See src/test_dbi.c for example usage. This requires c2lib >= 1.2.21.

Wed Oct 9 19:10:38 BST 2002: Added http_request_set_url method which is used by rws to update the URL during internal rewrites.

Sat Sep 7 15:38:33 BST 2002: Packages are now available as i686 binary RPMs and source RPMs.

Old news and old versions

Sat Aug 31 14:53:52 BST 2002

pthrlib-3.0.4.tar.gz released. This contains a complete tutorial and some documentation fixes.

Fri Aug 23 15:00:51 BST 2002

pthrlib-3.0.3.tar.gz released. This adds the copy_cgi and cgi_erase functions required by monolith.

Thu Aug 22 13:20:32 BST 2002

pthrlib-3.0.2.tar.gz released. This includes manual pages which were accidentally omitted from the previous version.

Wed Aug 21 14:20:12 BST 2002

pthrlib-3.0.1.tar.gz fixes a few silly bugs which stopped the new version of rws from working.

Wed Aug 21 11:59:17 BST 2002

pthrlib-3.0.0.tar.gz released. This version replaces the old pthr_server_main function with a newer, simpler pthr_server_main_loop function. The pthr_listener thread code has been modified slightly to allow multiple listeners to run at the same time (necessary for Fleet). This breaks a lot of old code, hence the major version number increase. All the included examples have been changed to support the new interface.

Fri Nov 16 10:43:00 GMT 2001

pthrlib-2.2.1.tar.gz released. A few bug fixes for glibc 2.2.4. You will need to use this version if you are using Red Hat Linux 7.x.

Mon Jul 9 07:43:07 BST 2001

pthrlib-2.2.0.tar.gz released. Added an FTP client library.

Fri Jun 15 15:46:10 BST 2001

pthrlib-2.1.6.tar.gz released. Stack support improved: stack overflows cause core dumps rather than random memory corruption; stacks are stored in memory mapped regions so they don't take memory unless you actually use them; stack size is configurable at run time. HTTP library uses exceptions for error messages. Support for profiling. Added a second example webserver. Tests for exception handling code. Added API call to allow you to count the number of threads running. Documentation updates.

Wed May 30 13:01:46 BST 2001

pthrlib-2.1.0.tar.gz released. This has experimental support for throw/catch-style exception handling. Please see the pth_die(3) and pth_catch(3) manual pages for full details.

Tue May 22 14:11:21 BST 2001

pthrlib-2.0.5.tar.gz released. Backed out previous URL-escaping patch. The fix goes better into rws instead.

Tue May 22 11:37:10 BST 2001

pthrlib-2.0.4.tar.gz released. URLs are now unescaped properly, allowing clients to correctly request URLs like '/%7Euser/'.

Tue Apr 10 16:04:41 BST 2001

pthrlib-2.0.2.tar.gz released. Added support for generating logfiles.

Mon Apr 9 17:23:59 BST 2001

pthrlib-2.0.1.tar.gz released. The http library component in version 1.x has been split more logically to support only the mechanics of parsing HTTP connections. The CGI part of it (eg. query string parsing, etc.) has been moved into a new library called cgi. This necessarily breaks older programs, hence the major version number increase. There are some other minor changes and bug fixes: the server name string can now be changed; CGI.pm-like POST_MAX can be set; fixed a really nasty bug in iolib -- it wasn't setting the output buffering mode to the correct default; fixed io_popen(3) so it can handle the case where fds 0 and/or 1 are already closed; added io_copy(3) function to copy bytes between two file descriptors; pthr_server_main now includes sys/types.h correctly.

Mon Mar 26 13:05:42 BST 2001

pthrlib-1.6.6.tar.gz released. Add -lm when linking with c2lib libraries. Documentation fixes.

Mon Mar 12 12:12:49 GMT 2001

pthrlib-1.6.5.tar.gz released. This fixes a bug in the way the library was calling pstrcat (in c2lib). Upgrading is highly recommended. You will also need to upgrade to the latest c2lib.

Fri Mar 9 17:32:13 GMT 2001

pthrlib-1.6.4.tar.gz released. Unit test suite added which covers much of the functionality. Fixed a nasty bug in io_popen. Fixed another nasty bug in the pseudothread code. Fixed a false assertion in the rwlock code (revealed during unit testing).

Fri Feb 23 16:37:58 GMT 2001

pthrlib-1.6.2.tar.gz released. pth_timeout function added and a nasty race condition in the reactor (which affected wait queues) fixed.

Fri Feb 16 18:02:46 GMT 2001

pthrlib-1.6.1.tar.gz released. All functions are documented in manual pages.

<% include page_footer.msp %> endef upload_website: scp $(PACKAGE)-$(VERSION).tar.gz $(PACKAGE)-$(VERSION)-1.*.rpm \ $(PACKAGE)-$(VERSION).bin.tar.gz \ 10.0.0.248:annexia.org/freeware/$(PACKAGE)/ scp index.html \ 10.0.0.248:annexia.org/freeware/$(PACKAGE)/index.msp .PHONY: build configure test upload_website