Recently has been plagued by this problem, the use of thttpd as an embedded httpserver for device upgrades, upload upgrade file when the server is always disconnected, because the first I used the Cgic library to encode, then the source analysis, found that cgic in processing upload data will be stored as temporary files, because the system flash is relatively small, there is not enough place to store temporary files, so the error, and later do not use the Cgic library for debugging, found that upload is still unsuccessful, began to trace and analyze the THTTPD source code, Thttpdserver found that the post way to upload files for different processing, because the initial search of a piece of information said THTTPD received the data also temporarily save for temporary files, so has been in the source to find this paragraph, and later found that THTTPD did not carry out temporary file storage, In his post operation, the branch processing, when the post page is a static page, other data directly discarded, but Config.h defined a linger_time set the time limit, when the post static page exceeds the Linger_time set time, The connection is accidentally interrupted. When the page being posted is a CGI file, he fork out two libhttpd.c in the Cgi_child function of the post, which corresponds to a pipeline in which one process receives data from the socket and then writes the pipe. The goal of the write pipe is to have the standard input stdin after the redirect, and the other subprocess to fetch the data from the standard output stdout (that is, the data returned to the browser), after which the post interrupt is found in the function of the pipe write operation (cgi_interpose_input), When writing to a standard input, because the data in stdin was not read in time, causing the pipe operation to fail, the problem was solved when the data was read from stdin in a CGI page synchronously using Fread.