Merged revisions 570-575,577-578 via svnmerge from
[senf.git] / Socket / ReadWritePolicy.cc
index d5c10c4..1e808a0 100644 (file)
@@ -53,7 +53,7 @@ prefix_ unsigned senf::ReadablePolicy::read(FileHandle handle, char * buffer,
                 rv = 0;
                 break;
             default:
-                throw SystemException(errno);
+                throwErrno();
             }
     } while (rv<0);
     return rv;
@@ -74,7 +74,7 @@ prefix_ unsigned senf::ReadablePolicy::do_readfrom(FileHandle handle, char * buf
                 rv = 0;
                 break;
             default:
-                throw SystemException(errno);
+                throwErrno();
             }
     } while (rv<0);
     return rv;
@@ -91,10 +91,16 @@ prefix_ unsigned senf::WriteablePolicy::do_write(FileHandle handle, char const *
             case EINTR:
                 break;
             case EAGAIN:
+            case ECONNREFUSED:
+                // Writing to a UDP socket seems return this error code if a corresponding ICMP
+                // error code has been received before (at least on linux). This is inconsistent
+                // since I cannot rely on getting ECONNREFUSED. I therefore ignore this error. TCP
+                // sockets will return this error on connect() and not on write(). Therefore we can
+                // unconditionally ignore this error here.
                 rv = 0;
                 break;
             default:
-                throw SystemException(errno);
+                throwErrno();
             }
     } while (rv<0);
     return rv;
@@ -115,7 +121,7 @@ prefix_ unsigned senf::WriteablePolicy::do_writeto(FileHandle handle,
                 rv = 0;
                 break;
             default:
-                throw SystemException(errno);
+                throwErrno();
             }
     } while (rv<0);
     return rv;