Kaynağa Gözat

Revert "hio_t add connected flag to avoid SIGPIPE by hio_write"

This reverts commit 27a86e3fef07be074f2a1764c23fe1cb68703be5.
ithewei 5 yıl önce
ebeveyn
işleme
f0b67f6be3
4 değiştirilmiş dosya ile 1 ekleme ve 10 silme
  1. 0 1
      event/hevent.h
  2. 1 1
      event/hloop.c
  3. 0 4
      event/nio.c
  4. 0 4
      event/overlapio.c

+ 0 - 1
event/hevent.h

@@ -88,7 +88,6 @@ struct hio_s {
     HEVENT_FIELDS
     // flags
     unsigned    ready       :1;
-    unsigned    connected   :1;
     unsigned    closed      :1;
     unsigned    accept      :1;
     unsigned    connect     :1;

+ 1 - 1
event/hloop.c

@@ -639,7 +639,7 @@ void hio_ready(hio_t* io) {
     if (io->ready) return;
     // flags
     io->ready = 1;
-    io->connected = io->closed = 0;
+    io->closed = 0;
     io->accept = io->connect = io->connectex = 0;
     io->recv = io->send = 0;
     io->recvfrom = io->sendto = 0;

+ 0 - 4
event/nio.c

@@ -52,7 +52,6 @@ static void __heartbeat_timer_cb(htimer_t* timer) {
 }
 
 static void __accept_cb(hio_t* io) {
-    io->connected = 1;
     /*
     char localaddrstr[SOCKADDR_STRLEN] = {0};
     char peeraddrstr[SOCKADDR_STRLEN] = {0};
@@ -79,7 +78,6 @@ static void __accept_cb(hio_t* io) {
 }
 
 static void __connect_cb(hio_t* io) {
-    io->connected = 1;
     /*
     char localaddrstr[SOCKADDR_STRLEN] = {0};
     char peeraddrstr[SOCKADDR_STRLEN] = {0};
@@ -496,7 +494,6 @@ int hio_read (hio_t* io) {
 }
 
 int hio_write (hio_t* io, const void* buf, size_t len) {
-    if (!io->connected) return -1;
     int nwrite = 0;
     if (write_queue_empty(&io->write_queue)) {
 try_write:
@@ -555,7 +552,6 @@ int hio_close (hio_t* io) {
         return 0;
     }
 
-    io->connected = 0;
     io->closed = 1;
     hio_done(io);
     __close_cb(io);

+ 0 - 4
event/overlapio.c

@@ -111,7 +111,6 @@ static void on_acceptex_complete(hio_t* io) {
     if (io->accept_cb) {
         setsockopt(connfd, SOL_SOCKET, SO_UPDATE_ACCEPT_CONTEXT, (const char*)&listenfd, sizeof(int));
         hio_t* connio = hio_get(io->loop, connfd);
-        connio->connected = 1;
         connio->userdata = io->userdata;
         memcpy(connio->localaddr, io->localaddr, localaddrlen);
         memcpy(connio->peeraddr, io->peeraddr, peeraddrlen);
@@ -138,7 +137,6 @@ static void on_connectex_complete(hio_t* io) {
         hio_close(io);
         return;
     }
-    io->connected = 1;
     if (io->connect_cb) {
         setsockopt(io->fd, SOL_SOCKET, SO_UPDATE_CONNECT_CONTEXT, NULL, 0);
         socklen_t addrlen = sizeof(struct sockaddr_in6);
@@ -302,7 +300,6 @@ int hio_read (hio_t* io) {
 }
 
 int hio_write(hio_t* io, const void* buf, size_t len) {
-    if (!io->connected) return -1;
     int nwrite = 0;
 try_send:
     if (io->io_type == HIO_TYPE_TCP) {
@@ -383,7 +380,6 @@ disconnect:
 
 int hio_close (hio_t* io) {
     if (io->closed) return 0;
-    io->connected = 0;
     io->closed = 1;
     hio_done(io);
     if (io->hovlp) {