aboutsummaryrefslogtreecommitdiffstats
path: root/src/interface.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/interface.c')
-rw-r--r--src/interface.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/interface.c b/src/interface.c
index 89229050d..29e372a5e 100644
--- a/src/interface.c
+++ b/src/interface.c
@@ -542,20 +542,21 @@ void flushAllInterfaceBuffers() {
}
}
-int interfacePrintWithFD(int fd,char * buffer) {
- int i;
- int buflen;
+int interfacePrintWithFD(int fd, char * buffer, int buflen) {
+ static int i = 0;
int copylen;
Interface * interface;
- if(!(buflen = strlen(buffer))) return -1;
-
- for(i=0;i<interface_max_connections;i++) {
- if(interfaces[i].open && interfaces[i].fd==fd) break;
+ if(i>=interface_max_connections ||
+ !interfaces[i].open || interfaces[i].fd!=fd)
+ {
+ for(i=0;i<interface_max_connections;i++) {
+ if(interfaces[i].open && interfaces[i].fd==fd) break;
+ }
+ if(i==interface_max_connections) return -1;
}
/* if fd isn't found or interfaces is going to be closed, do nothing */
- if(i==interface_max_connections) return -1;
if(interfaces[i].expired) return 0;
interface = interfaces+i;