forked from mirrors/tftp-hpa-google
Modernize: use sigaction() whenever possible. Remove uses of common.
bsd_signal() may not be defined, and there is really no reason to even try to use it if sigaction() is avaiable; using sigaction() guarantees the semantics we really want. Replace uses of common variables with explicit instantiation and extern declarations in a header file. Signed-off-by: H. Peter Anvin <hpa@zytor.com>
This commit is contained in:
parent
9c0908a778
commit
1f4b33a1f7
9 changed files with 64 additions and 42 deletions
|
@ -31,10 +31,13 @@
|
|||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef RECVFILE_H
|
||||
#define RECVFILE_H
|
||||
#ifndef EXTERN_H
|
||||
#define EXTERN_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
void tftp_recvfile(int, const char *, const char *);
|
||||
void tftp_sendfile(int, const char *, const char *);
|
||||
extern sigjmp_buf toplevel;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -305,7 +305,7 @@ int main(int argc, char *argv[])
|
|||
sp->s_proto = (char *)"udp";
|
||||
}
|
||||
|
||||
bsd_signal(SIGINT, intr);
|
||||
tftp_signal(SIGINT, intr);
|
||||
|
||||
if (peerargc) {
|
||||
/* Set peer */
|
||||
|
@ -768,7 +768,7 @@ void intr(int sig)
|
|||
{
|
||||
(void)sig; /* Quiet unused warning */
|
||||
|
||||
bsd_signal(SIGALRM, SIG_IGN);
|
||||
tftp_signal(SIGALRM, SIG_IGN);
|
||||
alarm(0);
|
||||
siglongjmp(toplevel, -1);
|
||||
}
|
||||
|
|
|
@ -48,8 +48,7 @@ extern int maxtimeout;
|
|||
#define PKTSIZE SEGSIZE+4
|
||||
char ackbuf[PKTSIZE];
|
||||
int timeout;
|
||||
sigjmp_buf toplevel;
|
||||
sigjmp_buf timeoutbuf;
|
||||
static sigjmp_buf timeoutbuf;
|
||||
|
||||
static void nak(int, const char *);
|
||||
static int makerequest(int, const char *, struct tftphdr *, const char *);
|
||||
|
@ -85,7 +84,7 @@ void tftp_sendfile(int fd, const char *name, const char *mode)
|
|||
is_request = 1; /* First packet is the actual WRQ */
|
||||
amount = 0;
|
||||
|
||||
bsd_signal(SIGALRM, timer);
|
||||
tftp_signal(SIGALRM, timer);
|
||||
do {
|
||||
if (is_request) {
|
||||
size = makerequest(WRQ, name, dp, mode) - 4;
|
||||
|
@ -191,7 +190,7 @@ void tftp_recvfile(int fd, const char *name, const char *mode)
|
|||
firsttrip = 1;
|
||||
amount = 0;
|
||||
|
||||
bsd_signal(SIGALRM, timer);
|
||||
tftp_signal(SIGALRM, timer);
|
||||
do {
|
||||
if (firsttrip) {
|
||||
size = makerequest(RRQ, name, ap, mode);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue