Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 546c201f authored by Mehmet Murat Sevim's avatar Mehmet Murat Sevim Committed by Automerger Merge Worker
Browse files

Merge "Fix potential data loss when writing to congested L2CAP CoC." am: dc47be77 am: cde94275

parents 387932f0 cde94275
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -442,10 +442,11 @@ static int process_cmd_sock(int h) {
  return true;
  return true;
}
}


static void process_data_sock(int h, struct pollfd* pfds, int count) {
static void process_data_sock(int h, struct pollfd* pfds, int pfds_count,
  asrt(count <= ts[h].poll_count);
                              int event_count) {
  asrt(event_count <= pfds_count);
  int i;
  int i;
  for (i = 1; i < ts[h].poll_count; i++) {
  for (i = 1; i < pfds_count; i++) {
    if (pfds[i].revents) {
    if (pfds[i].revents) {
      int ps_i = ts[h].psi[i];
      int ps_i = ts[h].psi[i];
      if (ts[h].ps[ps_i].pfd.fd == -1) {
      if (ts[h].ps[ps_i].pfd.fd == -1) {
@@ -512,6 +513,7 @@ static void* sock_poll_thread(void* arg) {
    }
    }
    if (ret != 0) {
    if (ret != 0) {
      int need_process_data_fd = true;
      int need_process_data_fd = true;
      int pfds_count = ts[h].poll_count;
      if (pfds[0].revents)  // cmd fd always is the first one
      if (pfds[0].revents)  // cmd fd always is the first one
      {
      {
        asrt(pfds[0].fd == ts[h].cmd_fdr);
        asrt(pfds[0].fd == ts[h].cmd_fdr);
@@ -524,7 +526,7 @@ static void* sock_poll_thread(void* arg) {
        else
        else
          ret--;  // exclude the cmd fd
          ret--;  // exclude the cmd fd
      }
      }
      if (need_process_data_fd) process_data_sock(h, pfds, ret);
      if (need_process_data_fd) process_data_sock(h, pfds, pfds_count, ret);
    } else {
    } else {
      LOG_INFO("no data, select ret: %d", ret);
      LOG_INFO("no data, select ret: %d", ret);
    };
    };