summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Troy <dave@popvox.com>2006-04-02 16:24:56 +0000
committerDavid Troy <dave@popvox.com>2006-04-02 16:24:56 +0000
commit55a533edf2e466a34179e12bf36e239902aad5fc (patch)
treee1cf773b24710eef2f0171e9a08895f57d6eedfc /src
parent8bdd2c1273d4ca4dd576f71ad5bae9bb7b38c5d5 (diff)
downloadastmanproxy-55a533edf2e466a34179e12bf36e239902aad5fc.tar.gz
astmanproxy-55a533edf2e466a34179e12bf36e239902aad5fc.tar.xz
astmanproxy-55a533edf2e466a34179e12bf36e239902aad5fc.zip
git-svn-id: http://svncommunity.digium.com/svn/astmanproxy/branches/1.20pre@57 f02b47b9-160a-0410-81a6-dc3441afb0ec
Diffstat (limited to 'src')
-rw-r--r--src/common.c32
-rw-r--r--src/proxyfunc.c32
-rw-r--r--src/ssl.c4
3 files changed, 34 insertions, 34 deletions
diff --git a/src/common.c b/src/common.c
index 5f63c15..8da909c 100644
--- a/src/common.c
+++ b/src/common.c
@@ -145,3 +145,35 @@ done:
}
return(0);
}
+
+/*! If you are calling ast_carefulwrite, it is assumed that you are calling
+ it on a file descriptor that _DOES_ have NONBLOCK set. This way,
+ there is only one system call made to do a write, unless we actually
+ have a need to wait. This way, we get better performance. */
+int ast_carefulwrite(int fd, char *s, int len, int timeoutms)
+{
+ /* Try to write string, but wait no more than ms milliseconds
+ before timing out */
+ int res=0;
+ struct pollfd fds[1];
+ while(len) {
+ res = m_send(fd, s, len);
+ if ((res < 0) && (errno != EAGAIN)) {
+ return -1;
+ }
+ if (res < 0) res = 0;
+ len -= res;
+ s += res;
+ res = 0;
+ if (len) {
+ fds[0].fd = get_real_fd(fd);
+ fds[0].events = POLLOUT;
+ /* Wait until writable again */
+ res = poll(fds, 1, timeoutms);
+ if (res < 1)
+ return -1;
+ }
+ }
+ return res;
+}
+
diff --git a/src/proxyfunc.c b/src/proxyfunc.c
index 2992267..54df298 100644
--- a/src/proxyfunc.c
+++ b/src/proxyfunc.c
@@ -387,35 +387,3 @@ void *SendError(struct mansession *s, char *errmsg) {
return 0;
}
-
-/*! If you are calling ast_carefulwrite, it is assumed that you are calling
- it on a file descriptor that _DOES_ have NONBLOCK set. This way,
- there is only one system call made to do a write, unless we actually
- have a need to wait. This way, we get better performance. */
-int ast_carefulwrite(int fd, char *s, int len, int timeoutms)
-{
- /* Try to write string, but wait no more than ms milliseconds
- before timing out */
- int res=0;
- struct pollfd fds[1];
- while(len) {
- res = m_send(fd, s, len);
- if ((res < 0) && (errno != EAGAIN)) {
- return -1;
- }
- if (res < 0) res = 0;
- len -= res;
- s += res;
- res = 0;
- if (len) {
- fds[0].fd = get_real_fd(fd);
- fds[0].events = POLLOUT;
- /* Wait until writable again */
- res = poll(fds, 1, timeoutms);
- if (res < 1)
- return -1;
- }
- }
- return res;
-}
-
diff --git a/src/ssl.c b/src/ssl.c
index 7ff4ab5..b884eac 100644
--- a/src/ssl.c
+++ b/src/ssl.c
@@ -142,8 +142,8 @@ int sec_getslot(void)
return i;
}
-/*! \brief Accepts the ssl connection. Retrurns the negative fd. negative fd's are
- * choosen to differentiate between ssl and non-ssl connections. positive
+/*! \brief Accepts the ssl connection. Returns the negative fd. negative fd's are
+ * chosen to differentiate between ssl and non-ssl connections. Positive
* fd's are used for non-ssl connections and negative fd's are used for ssl
* connections. So we purposefully calculate and return negative fds.
* You can always get positive fd by calling get_real_fd(negative fd).