Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to debug a weird threaded open fifo issue?
    primarykey
    data
    text
    <p>A web service is configured to expose some of its data when receiving a USR1 signal. The signal will be sent by a xinetd server when it receives a request from a remote client, e.g. nc myserver 50666. When the web server receives USR1 signal, it opens a dedicated fifo pipe, writes its data to the pipe, and then close the pipe. In the meantime, the xinetd server reads the pipe and feeds to the remote client.</p> <p>In most of times, they work nicely but occasionally, for some reason, the client will receive dup records. From the log, it seems like the pipe did not get closed properly and the cache is leftover, so when next time it serves, both previous and current are sent to the client. The problem is its not constantly happening when trying to reproduce, unluckily, I wasn't able to reproduce once. </p> <p>The following are the simple snippets to demonstrate the process:</p> <p>The web server: (webserver.py)</p> <pre><code>def SendStream(data, pipe): try: for i in data: pipe.write(i + '\n') pipe.flush() finally: pipe.close() def Serve(): threading.Thread(target=SendStream, args=(data, pipe)).start() </code></pre> <p>The xinetd.d server: (spitter.py)</p> <pre><code>def Serve(): if not os.path.exists(PIPE_FILE): os.mkfifo(PIPE_FILE) os.kill(server_pid, signal.SIGUSR1) for i in open(PIPE_FILE): print i, </code></pre> <p>So what exactly happened to cause the dup? How to trigger it? The current fix I unlink the pipe file and recreate it every time to avoid any leftovers but I don't know if that's a proper solution.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload