[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[or-cvs] better comments and a few patches
Update of /home/or/cvsroot/src/or
In directory moria.mit.edu:/home/arma/work/onion/cvs/src/or
Modified Files:
buffers.c dns.c main.c
Log Message:
better comments and a few patches
Index: buffers.c
===================================================================
RCS file: /home/or/cvsroot/src/or/buffers.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- buffers.c 26 Jan 2003 09:02:24 -0000 1.10
+++ buffers.c 4 Mar 2003 04:36:37 -0000 1.11
@@ -8,6 +8,10 @@
extern or_options_t options; /* command-line and config-file options */
+/* Create a new buf of size MAX_BUF_SIZE. Write a pointer to it
+ * into *buf, write MAX_BUF_SIZE into *buflen, and initialize
+ * *buf_datalen to 0. Return 0 if success, or -1 if malloc fails.
+ */
int buf_new(char **buf, int *buflen, int *buf_datalen) {
assert(buf && buflen && buf_datalen);
@@ -15,7 +19,7 @@
*buf = (char *)malloc(MAX_BUF_SIZE);
if(!*buf)
return -1;
- memset(*buf,0,MAX_BUF_SIZE);
+// memset(*buf,0,MAX_BUF_SIZE);
*buflen = MAX_BUF_SIZE;
*buf_datalen = 0;
@@ -26,13 +30,12 @@
free(buf);
}
+/* read from socket s, writing onto buf+buf_datalen. If at_most is >= 0 then
+ * read at most 'at_most' bytes, and in any case don't read more than will fit based on buflen.
+ * If read() returns 0, set *reached_eof to 1 and return 0. If you want to tear
+ * down the connection return -1, else return the number of bytes read.
+ */
int read_to_buf(int s, int at_most, char **buf, int *buflen, int *buf_datalen, int *reached_eof) {
-
- /* read from socket s, writing onto buf+buf_datalen. If at_most is >= 0 then
- * read at most 'at_most' bytes, and in any case don't read more than will fit based on buflen.
- * If read() returns 0, set *reached_eof to 1 and return 0. If you want to tear
- * down the connection return -1, else return the number of bytes read.
- */
int read_result;
Index: dns.c
===================================================================
RCS file: /home/or/cvsroot/src/or/dns.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- dns.c 18 Feb 2003 01:35:55 -0000 1.6
+++ dns.c 4 Mar 2003 04:36:37 -0000 1.7
@@ -156,7 +156,7 @@
if(dns_write_block(fd, "\0\0\0\0", 4) < 0) {
log(LOG_INFO,"dns_slave_main(): writing to master failed. Exiting.");
exit(0);
- }
+ }
} else {
if(dns_write_block(fd, rent->h_addr, rent->h_length) < 0) {
log(LOG_INFO,"dns_slave_main(): writing to master failed. Exiting.");
@@ -454,10 +454,9 @@
strncpy(search.question, exitconn->address, MAX_ADDRESSLEN);
- /* try adding it to the tree. if it's already there it will
- * return it. */
+ /* check the tree to see if 'question' is already there. */
resolve = SPLAY_FIND(cache_tree, &cache_root, &search);
- if(resolve) { /* already there. free up new_resolve */
+ if(resolve) { /* already there */
switch(resolve->state) {
case CACHE_STATE_PENDING:
/* add us to the pending list */
@@ -472,7 +471,7 @@
case CACHE_STATE_FAILED:
return -1;
}
- } else { /* this was newly added to the tree. ask the dns farm. */
+ } else { /* need to add it */
resolve = malloc(sizeof(struct cached_resolve));
memset(resolve, 0, sizeof(struct cached_resolve));
resolve->state = CACHE_STATE_PENDING;
Index: main.c
===================================================================
RCS file: /home/or/cvsroot/src/or/main.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- main.c 14 Feb 2003 07:53:54 -0000 1.39
+++ main.c 4 Mar 2003 04:36:37 -0000 1.40
@@ -650,6 +650,7 @@
}
init_tracked_tree(); /* initialize the replay detection tree */
+ init_cache_tree(); /* initialize the dns resolve tree */
signal (SIGINT, catch); /* catch kills so we can exit cleanly */
signal (SIGTERM, catch);