ippserver.c

steve haughton shaughton at astromed.com
Wed Apr 10 17:15:46 PDT 2013


I needed a small ipp server to add to a custom printer with an embedded linux system. After searching the web I found that someone asked the same question and and the suggestion was to use ippserver.c found in CUPS.

I modified the ippserver.c code to hard code the configuration: printer name,
server name, uri, doc formats and spool directory.

I very easily built cups 1.5.2 into the system with ippserver installed in the sbin directory.(OUTPUT BELOW)

I created a thread in the code and launched the server using:
system("/sbin/ippserver");

Everything worked great, I could print any files sent from the host and I could also access the web page. Unfortunately after many print jobs sent I recieved an "unable to create client thread: cannot allocate memory" error.

Looking at it closer it seems I lose memory with every print job.

Any ideas would be greatly appreciated,

Thx, Steve



Below is output at power on and after the error.

On POWER on

ps shows
92 root    4352 S   /sbin/ippserver
--------------------------------------------------------------
free shows
             total     used      free    shared      buffers
Mem:        517044   158300    358744         0       147456
-/+ buffers:          10844    506200
Swap:            0        0         0
--------------------------------------------------------------
df shows

Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root               142799     83626     59173  59% /
/dev/mtdblock3            8192       532      7660   6% /mnt/jffs2
mdev                    258520         0    258520   0% /dev
tmpfs                   131072        20    131052   0% /tmp
----------------------------------------------------------------
top shows
Mem: 158300K used, 358744K free, 0K shrd, 147456K buff, 3444K cached
CPU:  0.0% usr  0.1% sys  0.0% nic 99.8% idle  0.0% io  0.0% irq  0.0% sirq
Load average: 0.00 0.00 0.00 1/36 11166
  PID  PPID USER     STAT   VSZ %MEM %CPU COMMAND
   38     1 root     S    62056 11.9  0.2 /sbin/tw5_startup
   89     1 root     S     5772  1.1  0.0 /usr/sbin/snmpd
   92    91 root     S     4352  0.8  0.0 /sbin/ippserver
10915    41 root     R     2880  0.5  0.0 top
   41     1 root     S     2880  0.5  0.0 -sh
   73     1 root     S     2876  0.5  0.0 /usr/sbin/inetd -e
    1     0 root     S     2576  0.5  0.0 init
   35     1 root     S     2576  0.5  0.0 syslogd
   37     1 root     S     2576  0.5  0.0 klogd
   77    38 root     S     2576  0.5  0.0 sh -c tcpsvd -E 0 515 lpd /var/spool
   78    77 root     S     2576  0.5  0.0 tcpsvd -E 0 515 lpd /var/spool
   80    38 root     S     2576  0.5  0.0 sh -c nc -l -p 9100 >/var/spool/tw5/df
   81    80 root     S     2576  0.5  0.0 nc -l -p 9100
   91    38 root     S     2576  0.5  0.0 sh -c /sbin/ippserver
    5     2 root     SW<      0  0.0  0.0 [events/0]
    2     0 root     SW<      0  0.0  0.0 [kthreadd]
    3     2 root     SW<      0  0.0  0.0 [ksoftirqd/0]
    4     2 root     SW<      0  0.0  0.0 [watchdog/0]
    6     2 root     SW<      0  0.0  0.0 [khelper]
    7     2 root     SW<      0  0.0  0.0 [kblockd/0]



AFTER Error

ps shows
   92 root     1276m S    /sbin/ippserver

~ # df
Filesystem           1K-blocks      Used Available Use% Mounted on
/dev/root               142799     83627     59172  59% /
/dev/mtdblock3            8192       536      7656   7% /mnt/jffs2
mdev                    258520         0    258520   0% /dev
tmpfs                   131072        40    131032   0% /tmp


~ # free
             total         used         free       shared      buffers
Mem:        517044       169332       347712            0       147456
-/+ buffers:              21876       495168
Swap:            0            0            0

top shows
Mem: 169332K used, 347712K free, 0K shrd, 147456K buff, 7280K cached
CPU:  0.2% usr  0.0% sys  0.0% nic 99.6% idle  0.0% io  0.0% irq  0.2% sirq
Load average: 0.52 0.65 0.45 1/36 29707
  PID  PPID USER     STAT   VSZ %MEM %CPU COMMAND
   92    91 root     S    1276m252.2  0.3 /sbin/ippserver
   38     1 root     S    62056 11.9  0.0 /sbin/tw5_startup
   89     1 root     S     5900  1.1  0.0 /usr/sbin/snmpd
   41     1 root     S     2880  0.5  0.0 -sh
29495    41 root     R     2880  0.5  0.0 top
   73     1 root     S     2876  0.5  0.0 /usr/sbin/inetd -e
    1     0 root     S     2576  0.5  0.0 init
   37     1 root     S     2576  0.5  0.0 klogd
   35     1 root     S     2576  0.5  0.0 syslogd
   77    38 root     S     2576  0.5  0.0 sh -c tcpsvd -E 0 515 lpd /var/spool
   78    77 root     S     2576  0.5  0.0 tcpsvd -E 0 515 lpd /var/spool
   80    38 root     S     2576  0.5  0.0 sh -c nc -l -p 9100 >/var/spool/tw5/df
   81    80 root     S     2576  0.5  0.0 nc -l -p 9100
   91    38 root     S     2576  0.5  0.0 sh -c /sbin/ippserver
    5     2 root     SW<      0  0.0  0.0 [events/0]
   10     2 root     SW       0  0.0  0.0 [pdflush]
    2     0 root     SW<      0  0.0  0.0 [kthreadd]
    3     2 root     SW<      0  0.0  0.0 [ksoftirqd/0]
    4     2 root     SW<      0  0.0  0.0 [watchdog/0]
    6     2 root     SW<      0  0.0  0.0 [khelper]



--------------------------------------------------------------------
./configure --host=ppc-linux --build=x86-linux --target=ppc-linux --with-components=core --disable-ssl
checking for gawk... gawk
checking for ppc-linux-gcc... ppc-linux-gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... yes
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether ppc-linux-gcc accepts -g... yes
checking for ppc-linux-gcc option to accept ISO C89... none needed
checking how to run the C preprocessor... ppc-linux-gcc -E
checking for ppc-linux-g++... ppc-linux-g++
checking whether we are using the GNU C++ compiler... yes
checking whether ppc-linux-g++ accepts -g... yes
checking for ppc-linux-ranlib... ppc-linux-ranlib
checking for ar... /usr/bin/ar
checking for chmod... /bin/chmod
checking for htmldoc... no
checking for ld... /usr/bin/ld
checking for ln... /bin/ln
checking for mv... /bin/mv
checking for rm... /bin/rm
checking for rmdir... /bin/rmdir
checking for sed... /opt/eldk/bin/sed
checking for xdg-open... /usr/bin/xdg-open
checking for install-sh script... using /home/steveh/TW5_Projects/Proj_5/Rootfs/filesystem/packages/cups-1.5.2/install-sh
checking for pkg-config... /usr/bin/pkg-config
checking for library containing fmod... -lm
checking for library containing crypt... -lcrypt
checking for library containing getspent... none required
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking crypt.h usability... yes
checking crypt.h presence... yes
checking for crypt.h... yes
checking langinfo.h usability... yes
checking langinfo.h presence... yes
checking for langinfo.h... yes
checking malloc.h usability... yes
checking malloc.h presence... yes
checking for malloc.h... yes
checking shadow.h usability... yes
checking shadow.h presence... yes
checking for shadow.h... yes
checking for string.h... (cached) yes
checking for strings.h... (cached) yes
checking bstring.h usability... no
checking bstring.h presence... no
checking for bstring.h... no
checking usersec.h usability... no
checking usersec.h presence... no
checking for usersec.h... no
checking sys/ioctl.h usability... yes
checking sys/ioctl.h presence... yes
checking for sys/ioctl.h... yes
checking sys/param.h usability... yes
checking sys/param.h presence... yes
checking for sys/param.h... yes
checking sys/ucred.h usability... no
checking sys/ucred.h presence... no
checking for sys/ucred.h... no
checking scsi/sg.h usability... yes
checking scsi/sg.h presence... yes
checking for scsi/sg.h... yes
checking iconv.h usability... yes
checking iconv.h presence... yes
checking for iconv.h... yes
checking for library containing iconv_open... none required
checking sys/mount.h usability... yes
checking sys/mount.h presence... yes
checking for sys/mount.h... yes
checking sys/statfs.h usability... yes
checking sys/statfs.h presence... yes
checking for sys/statfs.h... yes
checking sys/statvfs.h usability... yes
checking sys/statvfs.h presence... yes
checking for sys/statvfs.h... yes
checking sys/vfs.h usability... yes
checking sys/vfs.h presence... yes
checking for sys/vfs.h... yes
checking for statfs... yes
checking for statvfs... yes
checking for strdup... yes
checking for strlcat... no
checking for strlcpy... no
checking for snprintf... yes
checking for vsnprintf... yes
checking for random... yes
checking for lrand48... yes
checking for arc4random... no
checking for geteuid... yes
checking for setpgid... yes
checking for vsyslog... yes
checking for sigaction... yes
checking for waitpid... yes
checking for wait3... yes
checking for tm_gmtoff member in tm structure... yes
checking for st_gen member in stat structure... no
checking for removefile... no
checking for usb_get_string_simple in -lusb... yes
checking usb.h usability... yes
checking usb.h presence... yes
checking for usb.h... yes
checking for library containing acl_init... no
checking for DBUS... no
checking if GCC supports -fstack-protector... yes
checking if GCC supports -fPIE... yes
checking if GCC supports -Wno-tautological-compare... no
checking whether to build image filters... yes
checking for library containing pow... none required
checking jpeglib.h usability... yes
checking jpeglib.h presence... yes
checking for jpeglib.h... yes
checking for jpeg_destroy_decompress in -ljpeg... yes
checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking for gzgets in -lz... yes
checking png.h usability... yes
checking png.h presence... yes
checking for png.h... yes
checking for png_create_read_struct in -lpng... yes
checking tiff.h usability... no
checking tiff.h presence... no
checking for tiff.h... no
checking for stdlib.h... (cached) yes
checking resolv.h usability... yes
checking resolv.h presence... yes
checking for resolv.h... yes
checking for library containing socket... none required
checking for library containing gethostbyaddr... none required
checking for library containing getifaddrs... none required
checking for library containing hstrerror... none required
checking for library containing rresvport_af... none required
checking for library containing __res_init... none required
checking for library containing getaddrinfo... none required
checking for library containing getnameinfo... none required
checking for struct sockaddr.sa_len... no
checking sys/sockio.h usability... no
checking sys/sockio.h presence... no
checking for sys/sockio.h... no
checking for AppleTalk/at_proto.h... no
checking for poll... yes
checking for epoll_create... yes
checking for kqueue... no
checking slp.h usability... no
checking slp.h presence... no
checking for slp.h... no
checking for krb5-config... no
checking ldap.h usability... yes
checking ldap.h presence... yes
checking for ldap.h... yes
checking for ldap_initialize in -lldap... yes
checking for ldap_start_tls in -lldap... yes
checking for ldap_set_rebind_proc in -lldap... yes
checking pthread.h usability... yes
checking pthread.h presence... yes
checking for pthread.h... yes
checking for pthread_create using -lpthreads... no
checking for pthread_create using -lpthread... yes
checking for dlopen in -ldl... yes
checking for pam_start in -lpam... yes
checking for pam_set_item in -lpam... yes
checking for pam_setcred in -lpam... yes
checking security/pam_appl.h usability... yes
checking security/pam_appl.h presence... yes
checking for security/pam_appl.h... yes
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... 64
checking for long long int... yes
checking for strtoll... yes
checking dns_sd.h usability... no
checking dns_sd.h presence... no
checking for dns_sd.h... no
checking for launch_msg... no
checking launch.h usability... no
checking launch.h presence... no
checking for launch.h... no
checking whether to use network default printers... yes
checking for default print user... lp
checking for default print group... lp
checking for default system groups... "sys root"
checking for pdftops... /usr/bin/pdftops
checking whether pdftops supports -origpagesizes... no
checking for java... /usr/bin/java
checking for perl... /usr/bin/perl
checking for php-cgi... no
checking for php... no
checking for python... /usr/bin/python
configure: creating ./config.status
config.status: creating Makedefs
config.status: creating conf/cupsd.conf
config.status: creating conf/mime.convs
config.status: creating conf/pam.std
config.status: creating conf/snmp.conf
config.status: creating cups-config
config.status: creating data/testprint
config.status: creating desktop/cups.desktop
config.status: creating doc/help/ref-cupsd-conf.html
config.status: creating doc/help/standard.html
config.status: creating doc/index.html
config.status: creating man/client.conf.man
config.status: creating man/cups-deviced.man
config.status: creating man/cups-driverd.man
config.status: creating man/cups-lpd.man
config.status: creating man/cupsaddsmb.man
config.status: creating man/cupsd.conf.man
config.status: creating man/cupsd.man
config.status: creating man/lpoptions.man
config.status: creating scheduler/cups-lpd.xinetd
config.status: creating scheduler/cups.sh
config.status: creating scheduler/cups.xml
config.status: creating scheduler/org.cups.cups-lpd.plist
config.status: creating templates/header.tmpl
config.status: creating packaging/cups.list
config.status: creating doc/de/index.html
config.status: creating templates/de/header.tmpl
config.status: creating doc/es/index.html
config.status: creating templates/es/header.tmpl
config.status: creating doc/eu/index.html
config.status: creating templates/eu/header.tmpl
config.status: creating doc/fr/index.html
config.status: creating templates/fr/header.tmpl
config.status: creating doc/hu/index.html
config.status: creating templates/hu/header.tmpl
config.status: creating doc/id/index.html
config.status: creating templates/id/header.tmpl
config.status: creating doc/it/index.html
config.status: creating doc/ja/index.html
config.status: creating templates/ja/header.tmpl
config.status: creating doc/pl/index.html
config.status: creating templates/pl/header.tmpl
config.status: creating doc/ru/index.html
config.status: creating templates/ru/header.tmpl
config.status: creating config.h
config.status: config.h is unchanged
----------------------------------------------------
make
Using ARCHFLAGS=
Using ALL_CFLAGS=-I.. -D_CUPS_SOURCE   -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT
Using ALL_CXXFLAGS=-I.. -D_CUPS_SOURCE   -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -D_THREAD_SAFE -D_REENTRANT
Using CC=ppc-linux-gcc
Using CXX=ppc-linux-gcc
Using DSOFLAGS=-L../cups  -Wl,-soname,all -shared -Wall -Wno-format-y2k -Wunused -fPIC -Os -g -fstack-protector -D_GNU_SOURCE
Using LDFLAGS=-L../cgi-bin -L../cups -L../filter -L../ppdc -L../scheduler -fPIE -pie -Wall -Wno-format-y2k -Wunused -fPIC -Os -g -fstack-protector -D_GNU_SOURCE
Using LIBS=-lcups    -lz -lpthread -lcrypt -lm
Making all in cups...
Compiling adminutil.c...
Compiling array.c...
Compiling attr.c...
Compiling auth.c...
Compiling backchannel.c...
Compiling backend.c...
Compiling conflicts.c...
Compiling custom.c...
Compiling debug.c...
Compiling dest.c...
Compiling dir.c...
Compiling emit.c...
Compiling encode.c...
Compiling file.c...
Compiling getdevices.c...
Compiling getifaddrs.c...
Compiling getputfile.c...
Compiling globals.c...
Compiling http.c...
Compiling http-addr.c...
Compiling http-addrlist.c...
Compiling http-support.c...
Compiling ipp.c...
Compiling ipp-support.c...
Compiling langprintf.c...
Compiling language.c...
Compiling localize.c...
Compiling mark.c...
Compiling md5.c...
Compiling md5passwd.c...
Compiling notify.c...
Compiling options.c...
Compiling page.c...
Compiling ppd.c...
Compiling ppd-cache.c...
Compiling pwg-media.c...
Compiling request.c...
Compiling sidechannel.c...
Compiling snmp.c...
Compiling snprintf.c...
Compiling string.c...
Compiling tempfile.c...
Compiling thread.c...
Compiling transcode.c...
Compiling usersys.c...
Compiling util.c...
Archiving libcups.a...
a - adminutil.o
a - array.o
a - attr.o
a - auth.o
a - backchannel.o
a - backend.o
a - conflicts.o
a - custom.o
a - debug.o
a - dest.o
a - dir.o
a - emit.o
a - encode.o
a - file.o
a - getdevices.o
a - getifaddrs.o
a - getputfile.o
a - globals.o
a - http.o
a - http-addr.o
a - http-addrlist.o
a - http-support.o
a - ipp.o
a - ipp-support.o
a - langprintf.o
a - language.o
a - localize.o
a - mark.o
a - md5.o
a - md5passwd.o
a - notify.o
a - options.o
a - page.o
a - ppd.o
a - ppd-cache.o
a - pwg-media.o
a - request.o
a - sidechannel.o
a - snmp.o
a - snprintf.o
a - string.o
a - tempfile.o
a - thread.o
a - transcode.o
a - usersys.o
a - util.o
Linking libcups.so.2...
Making all in test...
Compiling ippserver.c...
Linking ippserver...
Compiling ipptool.c...
Linking ipptool...
Linking ipptool-static...
Making all in data...
Making all in locale...
Compiling checkpo.c...
checkpo.c: In function 'abbreviate':
checkpo.c:324: warning: comparison is always true due to limited range of data type
Linking checkpo.o...
Compiling po2strings.c...
Linking po2strings.o...
Compiling strings2po.c...
Linking strings2po.o...
Compiling translate.c...
Linking translate.o...
Making all in fonts...





More information about the cups mailing list