~eday/libdrizzle/eday-dev

« back to all changes in this revision

Viewing changes to libdrizzle/conn.c

  • Committer: Eric Day
  • Date: 2009-10-06 08:38:34 UTC
  • Revision ID: eday@oddments.org-20091006083834-r1tyvdqqrbem6j4o
Changed state macros into inline functions.

Show diffs side-by-side

added added

removed removed

Lines of Context:
69
69
  con->events= 0;
70
70
  con->revents= 0;
71
71
 
72
 
  DRIZZLE_STATE_RESET(con)
 
72
  drizzle_state_reset(con);
73
73
}
74
74
 
75
75
drizzle_return_t drizzle_con_set_events(drizzle_con_st *con, short events)
350
350
  if (con->options & DRIZZLE_CON_READY)
351
351
    return DRIZZLE_RETURN_OK;
352
352
 
353
 
  if (DRIZZLE_STATE_NONE(con))
 
353
  if (drizzle_state_none(con))
354
354
  {
355
355
    if (!(con->options & DRIZZLE_CON_RAW_PACKET))
356
356
    {
357
 
      DRIZZLE_STATE_PUSH(con, drizzle_state_server_handshake_read)
358
 
      DRIZZLE_STATE_PUSH(con, drizzle_state_packet_read)
 
357
      drizzle_state_push(con, drizzle_state_server_handshake_read);
 
358
      drizzle_state_push(con, drizzle_state_packet_read);
359
359
    }
360
360
 
361
 
    DRIZZLE_STATE_PUSH(con, drizzle_state_connect)
362
 
    DRIZZLE_STATE_PUSH(con, drizzle_state_addrinfo)
 
361
    drizzle_state_push(con, drizzle_state_connect);
 
362
    drizzle_state_push(con, drizzle_state_addrinfo);
363
363
  }
364
364
 
365
365
  return drizzle_state_loop(con);
374
374
  if (con->options & DRIZZLE_CON_READY)
375
375
    return DRIZZLE_RETURN_OK;
376
376
 
377
 
  if (DRIZZLE_STATE_NONE(con))
 
377
  if (drizzle_state_none(con))
378
378
  {
379
 
    DRIZZLE_STATE_PUSH(con, drizzle_state_listen)
380
 
    DRIZZLE_STATE_PUSH(con, drizzle_state_addrinfo)
 
379
    drizzle_state_push(con, drizzle_state_listen);
 
380
    drizzle_state_push(con, drizzle_state_addrinfo);
381
381
  }
382
382
 
383
383
  return drizzle_state_loop(con);
562
562
    break;
563
563
  }
564
564
 
565
 
  DRIZZLE_STATE_POP(con)
 
565
  drizzle_state_pop(con);
566
566
  return DRIZZLE_RETURN_OK;
567
567
}
568
568
 
583
583
  {
584
584
    drizzle_set_error(con->drizzle, "drizzle_state_connect",
585
585
                      "could not connect");
586
 
    DRIZZLE_STATE_RESET(con)
 
586
    drizzle_state_reset(con);
587
587
    return DRIZZLE_RETURN_COULD_NOT_CONNECT;
588
588
  }
589
589
 
623
623
 
624
624
    if (errno == EINPROGRESS)
625
625
    {
626
 
      DRIZZLE_STATE_POP(con)
627
 
      DRIZZLE_STATE_PUSH(con, drizzle_state_connecting)
 
626
      drizzle_state_pop(con);
 
627
      drizzle_state_push(con, drizzle_state_connecting);
628
628
      return DRIZZLE_RETURN_OK;
629
629
    }
630
630
 
640
640
    return DRIZZLE_RETURN_ERRNO;
641
641
  }
642
642
 
643
 
  DRIZZLE_STATE_POP(con)
 
643
  drizzle_state_pop(con);
644
644
  return DRIZZLE_RETURN_OK;
645
645
}
646
646
 
654
654
  {
655
655
    if (con->revents & POLLOUT)
656
656
    {
657
 
      DRIZZLE_STATE_POP(con)
 
657
      drizzle_state_pop(con);
658
658
      return DRIZZLE_RETURN_OK;
659
659
    }
660
660
    else if (con->revents & (POLLERR | POLLHUP | POLLNVAL))
661
661
    {
662
662
      con->revents= 0;
663
 
      DRIZZLE_STATE_POP(con)
664
 
      DRIZZLE_STATE_PUSH(con, drizzle_state_connect)
 
663
      drizzle_state_pop(con);
 
664
      drizzle_state_push(con, drizzle_state_connect);
665
665
      con->addrinfo_next= con->addrinfo_next->ai_next;
666
666
      return DRIZZLE_RETURN_OK;
667
667
    }
730
730
      else if (errno == ECONNREFUSED)
731
731
      {
732
732
        con->revents= 0;
733
 
        DRIZZLE_STATE_POP(con)
734
 
        DRIZZLE_STATE_PUSH(con, drizzle_state_connect)
 
733
        drizzle_state_pop(con);
 
734
        drizzle_state_push(con, drizzle_state_connect);
735
735
        con->addrinfo_next= con->addrinfo_next->ai_next;
736
736
        return DRIZZLE_RETURN_OK;
737
737
      }
753
753
    break;
754
754
  }
755
755
 
756
 
  DRIZZLE_STATE_POP(con);
 
756
  drizzle_state_pop(con);;
757
757
  return DRIZZLE_RETURN_OK;
758
758
}
759
759
 
816
816
 
817
817
  con->buffer_ptr= con->buffer;
818
818
 
819
 
  DRIZZLE_STATE_POP(con);
 
819
  drizzle_state_pop(con);
820
820
  return DRIZZLE_RETURN_OK;
821
821
}
822
822
 
911
911
  if (con->fd == -1)
912
912
    return DRIZZLE_RETURN_ERRNO;
913
913
 
914
 
  DRIZZLE_STATE_POP(con);
 
914
  drizzle_state_pop(con);
915
915
  return DRIZZLE_RETURN_OK;
916
916
}
917
917