我正在为嵌入式平台开发一个应用程序,即 TI 运行 arago linux 的 DM385。
通过 http 上传大于 3-4 MB 的文件时,我遇到了一个奇怪的问题。
有时上传效果很好,有时文件被上传但数据被损坏,HTTP 标头出现在文件的二进制数据中间。
其他时候,我收到 glibc() 错误(malloc 或 free)或 SIGSEGV 和 boa 崩溃。
使用较小的文件(例如 1MB 或更少)时,一切正常。我试图通过在整个程序流程中添加各种调试打印来调试问题。这反过来确实减慢了服务器的操作并暂时解决了问题 - 文件上传每次都运行良好。
似乎在数据传输期间使用的一个文件描述符中发生了某种缓冲区欠载,但我无法真正指出任何具体的问题。
有人可以分享一些关于这个问题或类似问题的知识吗?
[从评论更新:]
构建期间的警告:
boa.c: In function 'main':
boa.c:290: warning: passing argument 4 of 'pthread_create' makes pointer from integer without a cast
boa.c:292: warning: implicit declaration of function 'onvif_dbg'
boa.c: In function 'create_server_socket_udp_hello':
boa.c:376: warning: unused variable 'one'
boa.c: At top level:
boa.c:374: warning: 'create_server_socket_udp_hello' defined but not used
buffer.c: In function 'req_flush':
buffer.c:219: warning: implicit declaration of function 'onvif_dbg'
cgi.c: In function 'uri_decoding':
cgi.c:329: warning: pointer targets in passing argument 1 of 'ascii_to_hex' differ in signedness
config.c: In function 'read_config_files':
config.c:294: warning: implicit declaration of function 'onvif_trace'
request.c: In function 'uri_mpeg4':
request.c:3327: warning: implicit declaration of function 'onvif_dbg'
request.c: In function 'process_requests':
request.c:4730: warning: suggest parentheses around assignment used as truth value
request.c: At top level:
request.c:49: warning: 'sts' defined but not used
In file included from response.c:26:
/home/user/IPNC_RDK/Source/ipnc_rdk/../ipnc_rdk/ipnc_app/interface/inc/system_default.h:16:1: warning: "IPNC_DM385" redefined
<command-line>: warning: this is the location of the previous definition
In file included from select.c:27:
onvif.h:33:12: warning: missing whitespace after the macro name
select.c: In function 'probe_thr':
select.c:46: warning: implicit declaration of function 'GetSysInfo'
select.c:46: warning: initialization makes pointer from integer without a cast
select.c:51: warning: control reaches end of non-void function
select.c: In function 'select_loop':
select.c:66: warning: implicit declaration of function 'pthread_create'
select.c:68: warning: implicit declaration of function 'onvif_dbg'