projects
/
citadel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
new url for lingering_close() description
[citadel.git]
/
webcit
/
tcp_sockets.c
diff --git
a/webcit/tcp_sockets.c
b/webcit/tcp_sockets.c
index 04c648a29bc275ab06a34d48cd6b9b868298be71..302c908c1031da4aaf0aedf37ffc27086f7d6e61 100644
(file)
--- a/
webcit/tcp_sockets.c
+++ b/
webcit/tcp_sockets.c
@@
-482,12
+482,12
@@
int client_write(StrBuf *ThisBuf)
}
if ((WCC->Hdr->http_sock == -1) ||
}
if ((WCC->Hdr->http_sock == -1) ||
- (
res = write(WCC->Hdr->http_sock,
- ptr,
-
count)) == -1)
{
+ (
(res = write(WCC->Hdr->http_sock, ptr, count)),
+ (res == -1)))
+ {
syslog(LOG_INFO, "client_write: Socket write failed (%s)\n", strerror(errno));
wc_backtrace(LOG_INFO);
syslog(LOG_INFO, "client_write: Socket write failed (%s)\n", strerror(errno));
wc_backtrace(LOG_INFO);
- return
res
;
+ return
-1
;
}
count -= res;
ptr += res;
}
count -= res;
ptr += res;
@@
-553,8
+553,9
@@
void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
wcsession *WCC = WC;
size_t bytes_read = 0;
int first = 1;
wcsession *WCC = WC;
size_t bytes_read = 0;
int first = 1;
+ int client_con_state = 0;
int chunked = 0;
int chunked = 0;
- StrBuf *BufHeader;
+ StrBuf *BufHeader
= NULL
;
StrBuf *Buf;
Buf = NewStrBuf();
StrBuf *Buf;
Buf = NewStrBuf();
@@
-611,7
+612,10
@@
void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
}
}
}
}
- while ((bytes_read < total_len) && (ServerRc == 6)) {
+ while ((bytes_read < total_len) &&
+ (ServerRc == 6) &&
+ (client_con_state == 0))
+ {
if (WCC->serv_sock==-1) {
FlushStrBuf(WCC->WBuf);
if (WCC->serv_sock==-1) {
FlushStrBuf(WCC->WBuf);
@@
-635,26
+639,25
@@
void serv_read_binary_to_http(StrBuf *MimeType, size_t total_len, int is_static,
StrBufPlain(MimeType, CT, -1);
http_transmit_headers(ChrPtr(MimeType), is_static, chunked);
StrBufPlain(MimeType, CT, -1);
http_transmit_headers(ChrPtr(MimeType), is_static, chunked);
- if (send_http(WCC->HBuf) < 0)
- break;
+ client_con_state = send_http(WCC->HBuf);
}
}
- if (
chunked
)
+ if (
(chunked) && (client_con_state == 0)
)
{
StrBufPrintf(BufHeader, "%s%x\r\n",
(first)?"":"\r\n",
StrLength (WCC->WBuf));
{
StrBufPrintf(BufHeader, "%s%x\r\n",
(first)?"":"\r\n",
StrLength (WCC->WBuf));
- if (send_http(BufHeader) < 0)
-
break
;
+ first = 0;
+
client_con_state = send_http(BufHeader)
;
}
}
- if (
send_http(WCC->WBuf) <
0)
-
break
;
+ if (
client_con_state ==
0)
+
client_con_state = send_http(WCC->WBuf)
;
FlushStrBuf(WCC->WBuf);
}
FlushStrBuf(WCC->WBuf);
}
- if (
chunked
)
+ if (
(chunked) && (client_con_state == 0)
)
{
StrBufPlain(BufHeader, HKEY("\r\n0\r\n\r\n"));
if (send_http(BufHeader) < 0)
{
StrBufPlain(BufHeader, HKEY("\r\n0\r\n\r\n"));
if (send_http(BufHeader) < 0)
@@
-1073,7
+1076,7
@@
long end_burst(void)
/*
* lingering_close() a`la Apache. see
/*
* lingering_close() a`la Apache. see
- * http://
www.apache.org/docs
/misc/fin_wait_2.html for rationale
+ * http://
httpd.apache.org/docs/2.0
/misc/fin_wait_2.html for rationale
*/
int lingering_close(int fd)
{
*/
int lingering_close(int fd)
{