Small storage embedded devices using THTTPD for file uploads encountered problems __ storage

Source: Internet
Author: User
Tags set time stdin temporary file storage

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.