From: <don...@is...> - 2003-09-24 22:50:11
|
Sam wrote (in multiple messages) ... > does it do what you want? The latest version (patches sent earlier) does appear to do what I want. > > I get the feeling that in order to do this properly we need at least > > one more standard function, something like write-byte-will-hang-p > > which is yet another thing I don't know how to implement. > I am afraid you will need a whole bunch of listen() analogues. Yes, but I now view that as "future work". What I have now seems sufficient for speeding up my "shared socket server". > > # WRITE-BYTE-ARRAY - Pseudo-Function for Broadcast-Streams: ... > > + /* what happens if different streams write different amounts? *** */ > > while (streamlist = STACK_0, consp(streamlist)) { > > STACK_0 = Cdr(streamlist); > > pushSTACK(Car(streamlist)); > > - write_byte_array(&STACK_0,bytearray_,start,len); > > + result = write_byte_array(&STACK_0,bytearray_,start,len,no_hang); > > skipSTACK(1); > > } > > skipSTACK(1); > > + return result; > > } > > I think you should return the minimum of all the write_byte_array() > values, i.e., the total number of character that were printed to every > stream. Not very good. The problem is that you generally use no-hang to print a sequence, then you find out how far you got and try again starting from there. Your solution would result in writing some parts multiple times. Right now I think I prefer the current solution where I just say that the operation is illegal/unsupported for certain types of streams. > > + /* *** have to put it in nonblocking mode, then restore it? */ > see EXT:SOCKET-OPTIONS This is again solved in later version. Turns out that socket-options isn't the way to do it. > note that full_write is used in bindings/glibc/linux.lisp Thanks for mentioning that. Is it possible to make trailing arguments optional in c? I've already changed a bunch of calls to full-write to add the extra argument. Is it ok to just change the one above also? > please try building --with-debug and CC=g++ too. Ok, easy enough. What's this supposed to do? Help me debug in gdb? Catch extra problems at compile time? At run time? ... ah, see below. > > #<OUTPUT BUFFERED FILE-STREAM (UNSIGNED-BYTE 8) #P"/tmp/foobar"> > > [currently no support for buffered] > > that should not be too hard. > I think read/no-hang _is_ supported on buffered streams. Right. I think of that as future work since I don't need it right now. > please work with the CVS head. > I cannot incorporate patches that are not made against the CVS head - > too much work (if Joerg will do that, it is fine with me). The flip side (for me) is that cvs is a fast moving target. There were lots of cvs updates in the time it took me to get this working. I hope if I get a cvs today and submit diffs tomorrow you'll be satisfied. Another concern - I imagine that the last release is more reliable than cvs. You think that's true? I want to build a version that I can use in a lot of places for a significant time. It seems more reasonable to build that from the last release. Of course, I can do that and still send you diffs from cvs to incorporate. > > +#ifdef O_NONBLOCK > > + if ( fcntl(fd,F_SETFL,fcntl_flags|O_NONBLOCK) <0) { > > + OS_error(); > > + } > > +#else # older Unices called it O_NDELAY > > + if ( fcntl(fd,F_SETFL,fcntl_flags|O_NDELAY) <0) { > > + OS_error(); > > + } > > +#endif > > please use START_NO_BLOCK() and END_NO_BLOCK() in unix.d in CVS head. I'll look at those when I get cvs. > libsigsegv is linked statically, so it is always in the binary > distribution. only if the binary distribution is built with it, I presume (Hmm, I thought I saw a report that suggested the opposite - downloaded a 2.31 binary then had to install libsigsegv to use it. Should I try to track this down and find out what really happened?) > it is not in the source distribution because it is a totally separate > project and is a configure-time dependency of CLISP. Still, if it's highly recommeded it seems like it should be included. The possibility that some day not every version of clisp will work with every version of libsigsegv is an even better argument for doing so. > > First, I welcome ideas about how to debug such things. > > $ ./configure --with-debug build-g > $ cd build-g > $ gdb > (gdb) run -B . -norc -m 750KW -i init.lisp Whoa! Without even make? => Starting program: -B . -norc -m 750KW -i init.lisp No executable file specified. Use the "file" or "exec-file" command. (gdb) I'll try the make first. Now that's not fair! When I do above I don't get the segfault! Before: export CC="gcc -g -DDEBUG_SPVW" ./configure --without-readline --without-unicode test13 ... make ... ./lisp.run -B . -N locale -Efile UTF-8 -Eterminal UTF-8 -norc -m 750KW -x "(and (load \"init.lisp\") (sys::%saveinitmem) (ext::exit))" SAFETY=0 SPVW_MIXED_BLOCKS_OPPOSITE TRIVIALMAP_MEMORY STACK depth: 23979 [added a little debugging output here] SP depth: 67109981 make: *** [interpreted.mem] Segmentation fault (core dumped) Now: ./configure --without-readline --without-unicode --with-debug test14 ... make ... ./lisp.run -B . -N locale -Efile UTF-8 -Eterminal UTF-8 -norc -m 750KW -x "(and (load \"init.lisp\") (sys::%saveinitmem) (ext::exit))" SAFETY=3 SPVW_MIXED_BLOCKS_OPPOSITE TRIVIALMAP_MEMORY STACK depth: 23979 SP depth: 67109990 i i i i i i i ooooo o ooooooo ooooo ooooo I I I I I I I 8 8 8 8 8 o 8 8 I \ `+' / I 8 8 8 8 8 8 ... no segfault I earlier tried export CC="gcc -g -DSAFETY=3" and that didn't solve the problem. I have been using -DDEBUG_SPVW so that's not it. The only new switch I see is -DDEBUG_OS_ERROR. Is that supposed to cure segfaults? Last compile of spvw: gcc -g -DDEBUG_SPVW -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -Wno-sign-compare -g -DDEBUG_OS_ERROR -DDEBUG_SPVW -DSAFETY=3 -DDYNAMIC_FFI -DNO_READLINE -I. -c spvw.c Previous: gcc -g -DDEBUG_SPVW -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -fomit-frame-pointer -Wno-sign-compare -O2 -fexpensive-optimizations -DDYNAMIC_FFI -DNO_READLINE -I. -c spvw.c The one before that: gcc -g -DSAFETY=3 -W -Wswitch -Wcomment -Wpointer-arith -Wimplicit -Wreturn-type -fomit-frame-pointer -Wno-sign-compare -O2 -fexpensive-optimizations -DDYNAMIC_FFI -DNO_READLINE -I. -c spvw.c > > open("/usr/lib/libreadline.so.3", O_RDONLY) = 4 > > > > For some reason still reading libreadline! > > Any idea why? > > you'd need to look at config.log and unixconf.h. But this shouldn't matter if I use --without-readline, should it? |