~clint-fewbar/ubuntu/lucid/mysql-dfsg-5.1/increase-killtimeout

« back to all changes in this revision

Viewing changes to vio/viosocket.c

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2009-12-08 03:05:40 UTC
  • mfrom: (1.1.4 upstream) (0.1.15 sid)
  • Revision ID: james.westby@ubuntu.com-20091208030540-l5xq57znyuy9ctgt
Tags: 5.1.41-3ubuntu1
* Merge from debian testing.  Remaining changes:
  - debian/control:
    + Don't provide a libmysqlclient15-dev package as long as there
      are packages still build-depending on libmysqlclient15-dev and
      mysql-dfsg-5.0 is in the archive.
    + Lower mailx from a Recommends to a Suggests to avoid pulling in a
      full MTA on all installs of mysql-server (LP: #259477)
  - debian/rules:
    + added -fno-strict-aliasing to CFLAGS to get around mysql testsuite
      build failures.
  - debian/additions/debian-start.inc.sh: support ANSI mode (LP: #310211)
  - Add AppArmor profile:
    + debian/apparmor-profile: apparmor profile
    + debian/rules, debian/mysql-server-5.1.files: install apparmor profile.
    + debian/mysql-server-5.1.dirs: add etc/apparmor.d/fore-complain
    + debian/mysql-server-5.1.postrm: remove symlink in force-complain/ on
      purge.
    + debian/mysql-server-5.1.README.Debian: add apparmor documentation.
    + debian/additions/my.cnf: Add warning about apparmor. (LP: #201799)
    + debian/mysql-esrver-5.1.postinst: reload apparmor profiles
  - debian/additions/my.cfn: remove language options. Error message files are
    located in a different direction in Mysql 5.0. Setting the language option
    to use /usr/share/mysql/english breaks 5.0. Both 5.0 and 5.1 use a 
    default value that works. (LP: #316974)
  - debian/mysql-server-5.1.postinst: Clear out the second password when
    setting up mysql. (LP: #344816)
  - mysql-server-core-5.1 package for files needed by Akonadi:
    + debian/control: create mysql-server-core-5.1 package
    + debian/mysql-server-core-5.1.files, debian/mysql-server-5.1.files:
      move core mysqld files to mysql-server-core-5.1 package.
  - debian/libmysqlclient16.symbols.amd64: remove amd64 symbols as it has
    not been correcly generated in Debian.
  - Add Apport hook: (LP: #354188):
    + debian/mysql-server-5.1.py: apport package hook
    + debian/mysql-server-5.1.files, debian/rules: install apport package hook
  - debian/addtions/my.cnf:
    + drop old_password option.
    + fix commentened logging options to use general_log and general_log_file.
  - Don't upgrade if there is an ndb management node configured (LP: #413792)
  - Set thread stack size to 192K rather than 128K. 128K is only useful on 
    systems with < 64M RAM and causes stack overrides with some SQL commands.
    See http://dev.mysql.com/doc/refman/5.1/en/server-system-varriables.html
    for more details. (LP: #426919)
  - Convert to upstart:
    + Add mysql-server-5.1.mysql.upstart
    + Dropped debian/mysql-server-5.1.mysql.init,
      debian/additions/mysqld_safe_syslog.cnf
    + debian/additions/my.cnf:
      * Removed pid declaration
      * Set up error logging to /var/log/mysql since we're not piping anything
        around logger anymore
    + Remove references to mysqld_safe in these files:
      * debian/rules, mysql-server-5.1.logcheck.ignore.paranoid
        mysql-server-5.1.logcheck.ignore.workstation, 
        mysql-server-5.1.logcheck.ignore.server
    + debian/mysql-server-5.1.postinst:
      * Replace calls to /etc/init.d with regular upstart calls
      * Remove reference to mysqld_safe
    + Dropped debian/patches/38_scripts_mysqld_safe.sh_signals.dpatch:
  - Dropped already merged upstream:
    + debian/{control,rules}: add and enable hardening build for PIE.
   

Show diffs side-by-side

added added

removed removed

Lines of Context:
261
261
{
262
262
  int r=0;
263
263
  DBUG_ENTER("vio_close");
264
 
#ifdef __WIN__
265
 
  if (vio->type == VIO_TYPE_NAMEDPIPE)
266
 
  {
267
 
#if defined(__NT__) && defined(MYSQL_SERVER)
268
 
    CancelIo(vio->hPipe);
269
 
    DisconnectNamedPipe(vio->hPipe);
270
 
#endif
271
 
    r=CloseHandle(vio->hPipe);
272
 
  }
273
 
  else
274
 
#endif /* __WIN__ */
 
264
 
275
265
 if (vio->type != VIO_CLOSED)
276
266
  {
 
267
    DBUG_ASSERT(vio->type ==  VIO_TYPE_TCPIP ||
 
268
      vio->type == VIO_TYPE_SOCKET ||
 
269
      vio->type == VIO_TYPE_SSL);
 
270
 
277
271
    DBUG_ASSERT(vio->sd >= 0);
278
272
    if (shutdown(vio->sd, SHUT_RDWR))
279
273
      r= -1;
417
411
 
418
412
 
419
413
#ifdef __WIN__
420
 
size_t vio_read_pipe(Vio * vio, uchar* buf, size_t size)
 
414
 
 
415
/*
 
416
  Finish pending IO on pipe. Honor wait timeout
 
417
*/
 
418
static int pipe_complete_io(Vio* vio, char* buf, size_t size, DWORD timeout_millis)
421
419
{
422
420
  DWORD length;
 
421
  DWORD ret;
 
422
 
 
423
  DBUG_ENTER("pipe_complete_io");
 
424
 
 
425
  ret= WaitForSingleObject(vio->pipe_overlapped.hEvent, timeout_millis);
 
426
  /*
 
427
    WaitForSingleObjects will normally return WAIT_OBJECT_O (success, IO completed)
 
428
    or WAIT_TIMEOUT.
 
429
  */
 
430
  if(ret != WAIT_OBJECT_0)
 
431
  {
 
432
    CancelIo(vio->hPipe);
 
433
    DBUG_PRINT("error",("WaitForSingleObject() returned  %d", ret));
 
434
    DBUG_RETURN(-1);
 
435
  }
 
436
 
 
437
  if (!GetOverlappedResult(vio->hPipe,&(vio->pipe_overlapped),&length, FALSE))
 
438
  {
 
439
    DBUG_PRINT("error",("GetOverlappedResult() returned last error  %d", 
 
440
      GetLastError()));
 
441
    DBUG_RETURN(-1);
 
442
  }
 
443
 
 
444
  DBUG_RETURN(length);
 
445
}
 
446
 
 
447
 
 
448
size_t vio_read_pipe(Vio * vio, uchar *buf, size_t size)
 
449
{
 
450
  DWORD bytes_read;
423
451
  DBUG_ENTER("vio_read_pipe");
424
452
  DBUG_PRINT("enter", ("sd: %d  buf: 0x%lx  size: %u", vio->sd, (long) buf,
425
453
                       (uint) size));
426
454
 
427
 
  if (!ReadFile(vio->hPipe, buf, size, &length, NULL))
428
 
    DBUG_RETURN(-1);
 
455
  if (!ReadFile(vio->hPipe, buf, (DWORD)size, &bytes_read,
 
456
      &(vio->pipe_overlapped)))
 
457
  {
 
458
    if (GetLastError() != ERROR_IO_PENDING)
 
459
    {
 
460
      DBUG_PRINT("error",("ReadFile() returned last error %d",
 
461
        GetLastError()));
 
462
      DBUG_RETURN((size_t)-1);
 
463
    }
 
464
    bytes_read= pipe_complete_io(vio, buf, size,vio->read_timeout_millis);
 
465
  }
429
466
 
430
 
  DBUG_PRINT("exit", ("%d", length));
431
 
  DBUG_RETURN((size_t) length);
 
467
  DBUG_PRINT("exit", ("%d", bytes_read));
 
468
  DBUG_RETURN(bytes_read);
432
469
}
433
470
 
434
471
 
435
472
size_t vio_write_pipe(Vio * vio, const uchar* buf, size_t size)
436
473
{
437
 
  DWORD length;
 
474
  DWORD bytes_written;
438
475
  DBUG_ENTER("vio_write_pipe");
439
476
  DBUG_PRINT("enter", ("sd: %d  buf: 0x%lx  size: %u", vio->sd, (long) buf,
440
477
                       (uint) size));
441
478
 
442
 
  if (!WriteFile(vio->hPipe, (char*) buf, size, &length, NULL))
443
 
    DBUG_RETURN(-1);
 
479
  if (!WriteFile(vio->hPipe, buf, (DWORD)size, &bytes_written,
 
480
      &(vio->pipe_overlapped)))
 
481
  {
 
482
    if (GetLastError() != ERROR_IO_PENDING)
 
483
    {
 
484
      DBUG_PRINT("vio_error",("WriteFile() returned last error %d",
 
485
        GetLastError()));
 
486
      DBUG_RETURN((size_t)-1);
 
487
    }
 
488
    bytes_written = pipe_complete_io(vio, (char *)buf, size, 
 
489
        vio->write_timeout_millis);
 
490
  }
444
491
 
445
 
  DBUG_PRINT("exit", ("%d", length));
446
 
  DBUG_RETURN((size_t) length);
 
492
  DBUG_PRINT("exit", ("%d", bytes_written));
 
493
  DBUG_RETURN(bytes_written);
447
494
}
448
495
 
 
496
 
449
497
int vio_close_pipe(Vio * vio)
450
498
{
451
499
  int r;
452
500
  DBUG_ENTER("vio_close_pipe");
453
 
#if defined(__NT__) && defined(MYSQL_SERVER)
454
 
  CancelIo(vio->hPipe);
 
501
 
 
502
  CloseHandle(vio->pipe_overlapped.hEvent);
455
503
  DisconnectNamedPipe(vio->hPipe);
456
 
#endif
457
 
  r=CloseHandle(vio->hPipe);
 
504
  r= CloseHandle(vio->hPipe);
458
505
  if (r)
459
506
  {
460
507
    DBUG_PRINT("vio_error", ("close() failed, error: %d",GetLastError()));
466
513
}
467
514
 
468
515
 
469
 
void vio_ignore_timeout(Vio *vio __attribute__((unused)),
470
 
                        uint which __attribute__((unused)),
471
 
                        uint timeout __attribute__((unused)))
 
516
void vio_win32_timeout(Vio *vio, uint which , uint timeout_sec)
472
517
{
 
518
    DWORD timeout_millis;
 
519
    /*
 
520
      Windows is measuring timeouts in milliseconds. Check for possible int 
 
521
      overflow.
 
522
    */
 
523
    if (timeout_sec > UINT_MAX/1000)
 
524
      timeout_millis= INFINITE;
 
525
    else
 
526
      timeout_millis= timeout_sec * 1000;
 
527
 
 
528
    /* which == 1 means "write", which == 0 means "read".*/
 
529
    if(which)
 
530
      vio->write_timeout_millis= timeout_millis;
 
531
    else
 
532
      vio->read_timeout_millis= timeout_millis;
473
533
}
474
534
 
475
535
 
504
564
         WAIT_ABANDONED_0 and WAIT_TIMEOUT - fail.  We can't read anything
505
565
      */
506
566
      if (WaitForMultipleObjects(array_elements(events), events, FALSE,
507
 
                                 vio->net->read_timeout*1000) != WAIT_OBJECT_0)
 
567
                                 vio->read_timeout_millis) != WAIT_OBJECT_0)
508
568
      {
509
569
        DBUG_RETURN(-1);
510
570
      };
561
621
  while (remain != 0)
562
622
  {
563
623
    if (WaitForMultipleObjects(array_elements(events), events, FALSE,
564
 
                               vio->net->write_timeout*1000) != WAIT_OBJECT_0)
 
624
                               vio->write_timeout_millis) != WAIT_OBJECT_0)
565
625
    {
566
626
      DBUG_RETURN((size_t) -1);
567
627
    }