0

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

1 回答 1

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'

解决这个问题。

于 2014-03-17T16:58:22.393 回答