Merge "adb: fix a data race in local_socket_event_func."

This commit is contained in:
Yabin Cui 2015-08-26 22:11:26 +00:00 committed by Gerrit Code Review
commit 804180b2cc

View file

@ -360,9 +360,12 @@ static void local_socket_event_func(int fd, unsigned ev, void* _s)
} else {
p->len = max_payload - avail;
// s->peer->enqueue() may call s->close() and free s,
// so save variables for debug printing below.
unsigned saved_id = s->id;
int saved_fd = s->fd;
r = s->peer->enqueue(s->peer, p);
D("LS(%d): fd=%d post peer->enqueue(). r=%d\n", s->id, s->fd,
r);
D("LS(%u): fd=%d post peer->enqueue(). r=%d\n", saved_id, saved_fd, r);
if (r < 0) {
/* error return means they closed us as a side-effect