Skip to content

Commit 69933c3

Browse files
committed
Removed debug printfs.
The code is doing what it's supposed to do now, so I've removed all of the debug output.
1 parent d39034b commit 69933c3

File tree

5 files changed

+2
-37
lines changed

5 files changed

+2
-37
lines changed

buffer.c

+1-6
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,6 @@ buf_read(struct channel *chp)
9595
buf_free(bp);
9696
return(-1);
9797
}
98-
printf("Read %d bytes.\n", bp->size);
99-
hexdump(bp->data, 0, bp->size);
10098
/*
10199
* Stick the buffer on the end of the channel read queue.
102100
*/
@@ -130,11 +128,8 @@ buf_write(struct channel *chp, int wrfd)
130128
*/
131129
bp = chp->bhead;
132130
chp->bhead = bp->next;
133-
if ((n = write(wrfd, bp->data, bp->size)) != bp->size) {
134-
syslog(LOG_INFO, "buffer write failure");
131+
if ((n = write(wrfd, bp->data, bp->size)) != bp->size)
135132
return(-1);
136-
}
137-
printf("Wrote %d bytes.\n", n);
138133
/*
139134
* Release the buffer and we're done.
140135
*/

channel.c

-14
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ chan_alloc()
8080
chp->totread = 0;
8181
chp->last_read = 0;
8282
chp->next = NULL;
83-
printf("New channel %d.\n", chp->channo);
8483
return(chp);
8584
}
8685

@@ -117,7 +116,6 @@ chan_process(struct queue *qp)
117116
* Channel has failed. Clean this up and move it to the
118117
* free Q.
119118
*/
120-
printf("Channel%d failure: %d\n", chp->channo, fail);
121119
chan_readoff(chp->fd);
122120
chan_writeoff(chp->fd);
123121
close(chp->fd);
@@ -143,7 +141,6 @@ chan_poll()
143141
*/
144142
memcpy((char *)&rfds, (char *)&mrdfdset, sizeof(fd_set));
145143
memcpy((char *)&wfds, (char *)&mwrfdset, sizeof(fd_set));
146-
printf(">>>> TOP OF LOOP: Select on %d FDs...\n", maxfds);
147144
if (contention()) {
148145
/*
149146
* We have contention - at least two channels want the device.
@@ -153,13 +150,7 @@ chan_poll()
153150
tvp = &tval;
154151
tvp->tv_sec = timeout;
155152
tvp->tv_usec = 0;
156-
printf("Timeout=%ds\n", timeout);
157-
} else {
158-
tvp = NULL;
159-
printf("No timeout\n");
160153
}
161-
if (busyq.head != NULL)
162-
printf("Head of queue is chan%d (contention=%d)\n", busyq.head->channo, contention());
163154
if ((n = select(maxfds, &rfds, &wfds, NULL, tvp)) < 0) {
164155
syslog(LOG_ERR, "select failure in chan_poll: %m");
165156
exit(1);
@@ -171,7 +162,6 @@ chan_poll()
171162
* the next guy (assuming there is one).
172163
*/
173164
time(&last_event);
174-
printf("Select returned %d.\n", n);
175165
if (contention() && (last_event - busyq.head->last_read) >= timeout) {
176166
qmove(busyq.head, IDLE_Q);
177167
slave_promote();
@@ -194,7 +184,6 @@ chan_poll()
194184
void
195185
chan_readon(int fd)
196186
{
197-
printf("Read ON on fd%d\n", fd);
198187
if (fd < 0)
199188
return;
200189
if (maxfds <= fd)
@@ -208,7 +197,6 @@ chan_readon(int fd)
208197
void
209198
chan_readoff(int fd)
210199
{
211-
printf("Read OFF on fd%d\n", fd);
212200
if (fd >= 0)
213201
FD_CLR(fd, &mrdfdset);
214202
}
@@ -219,7 +207,6 @@ chan_readoff(int fd)
219207
void
220208
chan_writeon(int fd)
221209
{
222-
printf("Write ON on fd%d\n", fd);
223210
if (fd < 0)
224211
return;
225212
if (maxfds <= fd)
@@ -233,7 +220,6 @@ chan_writeon(int fd)
233220
void
234221
chan_writeoff(int fd)
235222
{
236-
printf("Write OFF on fd%d\n", fd);
237223
if (fd >= 0)
238224
FD_CLR(fd, &mwrfdset);
239225
}

process.c

-7
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ struct channel *master = NULL;
4040
int
4141
master_read()
4242
{
43-
printf("MASTER Read!\n");
4443
/*
4544
* Do we have any slaves? If not, dump what we've just read.
4645
*/
@@ -56,7 +55,6 @@ master_read()
5655
chan_readoff(master->fd);
5756
else
5857
chan_readon(master->fd);
59-
printf("Master has %d bytes buffered.\n", master->totread);
6058
/*
6159
* OK, queue up the slave for writing...
6260
*/
@@ -72,7 +70,6 @@ master_write()
7270
{
7371
int n;
7472

75-
printf("MASTER Write!\n");
7673
if (busyq.head == NULL) {
7774
/*
7875
* Oops! No slaves. Nothing to see, here...
@@ -84,7 +81,6 @@ master_write()
8481
* Write data from the current head of the busy Q to the
8582
* master socket. Disable writes if there's no more data.
8683
*/
87-
printf("Slave channel %d wants to write.\n", busyq.head->channo);
8884
n = buf_write(busyq.head, master->fd);
8985
if (busyq.head->bhead == NULL)
9086
chan_writeoff(master->fd);
@@ -99,7 +95,6 @@ slave_read(struct channel *chp)
9995
{
10096
int n;
10197

102-
printf("SLAVE Read on channel %d\n", chp->channo);
10398
/*
10499
* If we've a lot of data backed up, stop reading (for now).
105100
*/
@@ -125,7 +120,6 @@ slave_read(struct channel *chp)
125120
int
126121
slave_write(struct channel *chp)
127122
{
128-
printf("SLAVE Write on channel %d\n", chp->channo);
129123
if (master->bhead == NULL || chp != busyq.head) {
130124
/*
131125
* Oops! Nothing to write. Dunno how we got here, but
@@ -151,7 +145,6 @@ void
151145
slave_promote()
152146
{
153147
if (busyq.head && busyq.head->bhead != NULL) {
154-
printf("Promoting chan%d to head of queue...\n", busyq.head->channo);
155148
chan_writeon(master->fd);
156149
busyq.head->last_read = last_event;
157150
}

serial.c

-2
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ serial_master(char *argstr)
7272
char *settings, *params[4];
7373
struct termios tios;
7474

75-
printf("Serial Init: [%s]\n", argstr);
7675
/*
7776
* Baud rate and settings are configured as follows:
7877
* /dev/ttyUSB0:9600:8N1 (for example).
@@ -92,7 +91,6 @@ serial_master(char *argstr)
9291
/*
9392
* Get and set the tty parameters.
9493
*/
95-
printf(">SERIAL FD%d:, Spd: %d, Params: [%s]\n", master->fd, baud, settings);
9694
if (tcgetattr(master->fd, &tios) < 0) {
9795
perror("serial_master: tcgetattr failed");
9896
exit(1);

tcpip.c

+1-8
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ tcp_init(int port)
4848
int yes = 1;
4949
struct sockaddr_in sin;
5050

51-
printf("TCP INIT: Port%d\n", port);
5251
if ((accept_fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
5352
perror("tcp_init: socket failed");
5453
exit(1);
@@ -66,7 +65,6 @@ tcp_init(int port)
6665
exit(1);
6766
}
6867
listen(accept_fd, 64);
69-
printf("LISTEN Socket UP!\n");
7068
chan_readon(accept_fd);
7169
}
7270

@@ -81,15 +79,12 @@ tcp_newconn()
8179
struct channel *chp;
8280
struct sockaddr_in sin;
8381

84-
printf("New connection received.\n");
85-
len = sizeof(struct sockaddr_in);
8682
chp = chan_alloc();
87-
printf("Going to accept...\n");
83+
len = sizeof(struct sockaddr_in);
8884
if ((chp->fd = accept(accept_fd, (struct sockaddr *)&sin, &len)) < 0) {
8985
syslog(LOG_INFO, "tcp_newconn failed: %m");
9086
return(-1);
9187
}
92-
printf("Back from accept(). Addr:[%08x]\n", sin.sin_addr.s_addr);
9388
chan_readon(chp->fd);
9489
return(1);
9590
}
@@ -105,7 +100,6 @@ tcp_master(char *argstr)
105100
struct sockaddr_in sin;
106101
in_addr_t addr;
107102

108-
printf("TCP Remote Init: [%s]\n", argstr);
109103
if ((i = crack(argstr, params, 4)) < 1)
110104
usage();
111105
host = params[0];
@@ -121,7 +115,6 @@ tcp_master(char *argstr)
121115
}
122116
memcpy((char *)&addr, hp->h_addr, hp->h_length);
123117
}
124-
printf("%08x\n", addr);
125118
master = chan_alloc();
126119
if ((master->fd = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
127120
perror("tcp_master: socket");

0 commit comments

Comments
 (0)