I'm developing an application for an embedded platform, namely DM385 by TI running arago linux.
I've encountered a strange problem when uploading files larger than 3-4 MB via http.
Sometimes the upload works well, other times the file gets uploaded but the data gets corrupted with the HTTP header appearing in the middle of the file's binary data.
Other times, I get a glibc() error (malloc or free) or SIGSEGV and boa crashes.
When using smaller files, like 1MB or less, everything works well. I've tried to debug the issue by adding vairous debug prints throughout the program's flow. This in turn really slowed down the server's operation and temporarily resolved the problem - the file upload worked well every single time.
It seems like there is some kind of buffer underrun occuring in one of the file descriptors being used during the data transfer but I can't really point my finger on anything specific.
Could somebody share some knowledge regarding this issue or similar ones?
[updated from comment:]
The warnings during build:
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'
The best would be to fix all warnings.
However (the comments refer to the warning above them):
Inspect this one, it might be fatal.
Fix this.
Not nice, but harmless.
Not nice, but harmless.
Fix this.
Inspect this one, it might be fatal.
Fix this.
Fix this.
Inspect this one, it might be fatal.
Not nice, but harmless.
Inspect this one, it might be fatal.
Inspect this one, it might be fatal.
Fix this.
Fix this.
Fix this.
Fix this.
Fix this.