mirror of
https://github.com/brmlab/brmlife.git
synced 2025-08-03 18:33:39 +02:00
connection::thread_loop(): Do not write() if we have nothing to write
This commit is contained in:
parent
296f4148d3
commit
f6221436a4
1 changed files with 10 additions and 8 deletions
|
@ -94,14 +94,16 @@ connection::thread_loop(void)
|
||||||
buf = out_buf;
|
buf = out_buf;
|
||||||
pthread_mutex_unlock(&buf_lock);
|
pthread_mutex_unlock(&buf_lock);
|
||||||
|
|
||||||
len = write(fd, buf.c_str(), buf.size());
|
if (buf.size() > 0) {
|
||||||
if (len < 0) {
|
len = write(fd, buf.c_str(), buf.size());
|
||||||
pthread_mutex_lock(&cancel_lock);
|
if (len < 0) {
|
||||||
error = true;
|
pthread_mutex_lock(&cancel_lock);
|
||||||
} else {
|
error = true;
|
||||||
pthread_mutex_lock(&buf_lock);
|
} else {
|
||||||
out_buf.erase(0, len);
|
pthread_mutex_lock(&buf_lock);
|
||||||
pthread_mutex_unlock(&buf_lock);
|
out_buf.erase(0, len);
|
||||||
|
pthread_mutex_unlock(&buf_lock);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue