将大型(~4MB)文件上传到boa webserver时出现不可预知的行为

时间:2014-03-13 12:19:58

标签: c linux glibc sigsegv boa

我正在开发一个嵌入式平台的应用程序,即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'

1 个答案:

答案 0 :(得分:1)

最好的办法是修复所有警告。

然而(评论引用了上面的警告):

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'

解决此问题。