gpt4 book ai didi

c - 将大型 (~4MB) 文件上传到 boa 网络服务器时出现不可预测的行为

转载 作者:太空宇宙 更新时间:2023-11-04 11:12:38 26 4
gpt4 key购买 nike

我正在为一个嵌入式平台开发一个应用程序,即 TI 运行 arago linux 的 DM385。

我在通过 http 上传大于 3-4 MB 的文件时遇到了一个奇怪的问题。

有时上传工作正常,有时文件上传但数据被损坏,HTTP header 出现在文件二进制数据的中间。

其他时候,我会遇到 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'

最佳答案

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

但是(评论指的是上面的警告):

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'

解决这个问题。

关于c - 将大型 (~4MB) 文件上传到 boa 网络服务器时出现不可预测的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22378462/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com