This is the mail archive of the ecos-discuss@sourceware.org mailing list for the eCos project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

tftp server:re-use of loop iterator in nested loop when CYGSEM_NET_TFTPD_MULTITHREADED=1


Hello,

We were looking at the code ecos/packages/net/common/current/src/tftp_server.c.
(ecos 3.x)
In the function 'tftpd_server(cyg_addrword_t p)', lines 647-668, the iterator 'i' is used in 2 nested for loops:


for (i=0; i < CYGNUM_NET_MAX_INET_PROTOS; i++) {
if (server->s[i] && FD_ISSET(server->s[i],&readfds)) {
recv_len = sizeof(data);
from_len = sizeof(from_addr);
data_len = recvfrom(server->s[i], hdr, recv_len, 0,
&from_addr, &from_len);
if ( data_len < 0) {
diag_printf("TFTPD [%x]: can't read request\n", p);
} else {
#ifdef CYGSEM_NET_TFTPD_MULTITHREADED
// Close the socket and post on the semaphore some
// another thread can start listening for requests. This
// is not quite right. select could of returned with more than
// one socket with data to read. Here we only deal with one of them
for (i=0; i < CYGNUM_NET_MAX_INET_PROTOS; i++) {
if (server->s[i]) {
close (server->s[i]);
server->s[i] = 0;
}
}
sem_post(server->port);
#endif


At first sight, I would say this is a bug, or am I wrong?

Kind regards,
Jürgen

--
Jürgen Lambrecht
R&D Associate
Tel: +32 (0)51 303045    Fax: +32 (0)51 310670
http://www.televic-rail.com
Televic Rail NV - Leo Bekaertlaan 1 - 8870 Izegem - Belgium
Company number 0825.539.581 - RPR Kortrijk


-- Before posting, please read the FAQ: http://ecos.sourceware.org/fom/ecos and search the list archive: http://ecos.sourceware.org/ml/ecos-discuss


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]