~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to libdrizzle/conn.c

  • Committer: Stewart Smith
  • Author(s): Vasil Dimov, Stewart Smith
  • Date: 2010-12-20 02:24:00 UTC
  • mto: (2021.1.2 build)
  • mto: This revision was merged to the branch mainline in revision 2022.
  • Revision ID: stewart@flamingspork.com-20101220022400-0p9lvvppwgaowdju
Merge Revision revid:vasil.dimov@oracle.com-20101102165720-164z3666y3tut4c2 from MySQL InnoDB

Original revid:vasil.dimov@oracle.com-20101102165720-164z3666y3tut4c2

Original Authors: Vasil Dimov <vasil.dimov@oracle.com>
Original commit message:
Fix Bug#53046 dict_update_statistics_low can still be run concurrently on same table

Replace the array of mutexes that used to protect
dict_index_t::stat_n_diff_key_vals[] with an array of rw locks that protects
all the stats related members in dict_table_t and all of its indexes.

Approved by:    Jimmy (rb://503)

Show diffs side-by-side

added added

removed removed

Lines of Context:
950
950
    con->buffer_ptr= con->buffer;
951
951
  }
952
952
 
953
 
  if ((con->revents & POLLIN) == 0 &&
954
 
      (con->drizzle->options & DRIZZLE_NON_BLOCKING))
955
 
  {
956
 
    /* non-blocking mode: return IO_WAIT instead of attempting to read. This
957
 
     * avoids reading immediately after writing a command, which typically
958
 
     * returns EAGAIN. This improves performance. */
959
 
    ret= drizzle_con_set_events(con, POLLIN);
960
 
    if (ret != DRIZZLE_RETURN_OK)
961
 
      return ret;
962
 
    return DRIZZLE_RETURN_IO_WAIT;
963
 
  }
964
 
 
965
953
  while (1)
966
954
  {
967
 
    size_t available_buffer= (size_t)DRIZZLE_MAX_BUFFER_SIZE -
968
 
        ((size_t)(con->buffer_ptr - con->buffer) + con->buffer_size);
969
955
    read_size = recv(con->fd, (char *)con->buffer_ptr + con->buffer_size,
970
 
                     available_buffer, 0);
 
956
                     (size_t)DRIZZLE_MAX_BUFFER_SIZE -
 
957
                     ((size_t)(con->buffer_ptr - con->buffer) +
 
958
                      con->buffer_size),0); 
971
959
#ifdef _WIN32
972
960
    /*Get windows error codes and map it to Posix*/
973
961
    errno = WSAGetLastError();
993
981
    {
994
982
      if (errno == EAGAIN)
995
983
      {
996
 
        /* clear the read ready flag */
997
 
        con->revents&= ~POLLIN;
998
984
        ret= drizzle_con_set_events(con, POLLIN);
999
985
        if (ret != DRIZZLE_RETURN_OK)
1000
 
          return ret;
 
986
          return 0;
1001
987
 
1002
988
        if (con->drizzle->options & DRIZZLE_NON_BLOCKING)
1003
989
          return DRIZZLE_RETURN_IO_WAIT;
1030
1016
      return DRIZZLE_RETURN_ERRNO;
1031
1017
    }
1032
1018
 
1033
 
    /* clear the "read ready" flag if we read all available data. */
1034
 
    if ((size_t) read_size < available_buffer) con->revents&= ~POLLIN;
1035
1019
    con->buffer_size+= (size_t)read_size;
1036
1020
    break;
1037
1021
  }
1038
1022
 
1039
 
  drizzle_state_pop(con);
 
1023
  drizzle_state_pop(con);;
1040
1024
  return DRIZZLE_RETURN_OK;
1041
1025
}
1042
1026
 
1319
1303
  }
1320
1304
 
1321
1305
#if defined (_WIN32)
1322
 
  {
1323
 
    unsigned long asyncmode;
1324
 
    asyncmode= 1;
1325
 
    ioctlsocket(con->fd, FIONBIO, &asyncmode);
1326
 
  }
 
1306
  unsigned long asyncmode = 1;
 
1307
  ioctlsocket(con->fd, FIONBIO, &asyncmode);
1327
1308
#else
1328
1309
  ret= fcntl(con->fd, F_GETFL, 0);
1329
1310
  if (ret == -1)