mp.c (36314) | mp.c (36345) |
---|---|
1/*- 2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * | 1/*- 2 * Copyright (c) 1998 Brian Somers <brian@Awfulhak.org> 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 9 unchanged lines hidden (view full) --- 18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24 * SUCH DAMAGE. 25 * |
26 * $Id: mp.c,v 1.4 1998/05/23 17:05:28 brian Exp $ | 26 * $Id: mp.c,v 1.5 1998/05/23 22:24:46 brian Exp $ |
27 */ 28 29#include <sys/types.h> 30#include <netinet/in.h> 31#include <netinet/in_systm.h> 32#include <netinet/ip.h> 33#include <arpa/inet.h> 34#include <net/if_dl.h> --- 821 unchanged lines hidden (view full) --- 856 if (s->send.dl != NULL) { 857 /* We've connect()ed */ 858 if (!link_QueueLen(&s->send.dl->physical->link) && 859 !s->send.dl->physical->out) { 860 /* Only send if we've transmitted all our data (i.e. the ConfigAck) */ 861 result -= datalink_RemoveFromSet(s->send.dl, r, w, e); 862 bundle_SendDatalink(s->send.dl, s->fd, &s->socket); 863 s->send.dl = NULL; | 27 */ 28 29#include <sys/types.h> 30#include <netinet/in.h> 31#include <netinet/in_systm.h> 32#include <netinet/ip.h> 33#include <arpa/inet.h> 34#include <net/if_dl.h> --- 821 unchanged lines hidden (view full) --- 856 if (s->send.dl != NULL) { 857 /* We've connect()ed */ 858 if (!link_QueueLen(&s->send.dl->physical->link) && 859 !s->send.dl->physical->out) { 860 /* Only send if we've transmitted all our data (i.e. the ConfigAck) */ 861 result -= datalink_RemoveFromSet(s->send.dl, r, w, e); 862 bundle_SendDatalink(s->send.dl, s->fd, &s->socket); 863 s->send.dl = NULL; |
864 close(s->fd); | |
865 s->fd = -1; 866 } else 867 /* Never read from a datalink that's on death row ! */ 868 result -= datalink_RemoveFromSet(s->send.dl, r, NULL, NULL); 869 } else if (r && s->fd >= 0) { 870 if (*n < s->fd + 1) 871 *n = s->fd + 1; 872 FD_SET(s->fd, r); --- 21 unchanged lines hidden (view full) --- 894 fd = accept(s->fd, &in, &size); 895 if (fd < 0) { 896 log_Printf(LogERROR, "mpserver_Read: accept(): %s\n", strerror(errno)); 897 return; 898 } 899 900 if (in.sa_family == AF_LOCAL) 901 bundle_ReceiveDatalink(bundle, fd, (struct sockaddr_un *)&in); | 864 s->fd = -1; 865 } else 866 /* Never read from a datalink that's on death row ! */ 867 result -= datalink_RemoveFromSet(s->send.dl, r, NULL, NULL); 868 } else if (r && s->fd >= 0) { 869 if (*n < s->fd + 1) 870 *n = s->fd + 1; 871 FD_SET(s->fd, r); --- 21 unchanged lines hidden (view full) --- 893 fd = accept(s->fd, &in, &size); 894 if (fd < 0) { 895 log_Printf(LogERROR, "mpserver_Read: accept(): %s\n", strerror(errno)); 896 return; 897 } 898 899 if (in.sa_family == AF_LOCAL) 900 bundle_ReceiveDatalink(bundle, fd, (struct sockaddr_un *)&in); |
902 903 close(fd); | 901 else 902 close(fd); |
904} 905 906static void 907mpserver_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) 908{ 909 /* We never want to write here ! */ 910 log_Printf(LogERROR, "mpserver_Write: Internal error: Bad call !\n"); 911} --- 77 unchanged lines hidden (view full) --- 989} 990 991void 992mpserver_Close(struct mpserver *s) 993{ 994 if (s->send.dl != NULL) { 995 bundle_SendDatalink(s->send.dl, s->fd, &s->socket); 996 s->send.dl = NULL; | 903} 904 905static void 906mpserver_Write(struct descriptor *d, struct bundle *bundle, const fd_set *fdset) 907{ 908 /* We never want to write here ! */ 909 log_Printf(LogERROR, "mpserver_Write: Internal error: Bad call !\n"); 910} --- 77 unchanged lines hidden (view full) --- 988} 989 990void 991mpserver_Close(struct mpserver *s) 992{ 993 if (s->send.dl != NULL) { 994 bundle_SendDatalink(s->send.dl, s->fd, &s->socket); 995 s->send.dl = NULL; |
997 close(s->fd); | |
998 s->fd = -1; 999 } else if (s->fd >= 0) { 1000 close(s->fd); 1001 if (ID0unlink(s->socket.sun_path) == -1) 1002 log_Printf(LogERROR, "%s: Failed to remove: %s\n", s->socket.sun_path, 1003 strerror(errno)); 1004 memset(&s->socket, '\0', sizeof s->socket); 1005 s->fd = -1; 1006 } 1007} 1008 1009void 1010mp_LinkLost(struct mp *mp, struct datalink *dl) 1011{ 1012 if (mp->seq.min_in == dl->mp.seq) 1013 /* We've lost the link that's holding everything up ! */ 1014 mp_Input(mp, NULL, NULL); 1015} | 996 s->fd = -1; 997 } else if (s->fd >= 0) { 998 close(s->fd); 999 if (ID0unlink(s->socket.sun_path) == -1) 1000 log_Printf(LogERROR, "%s: Failed to remove: %s\n", s->socket.sun_path, 1001 strerror(errno)); 1002 memset(&s->socket, '\0', sizeof s->socket); 1003 s->fd = -1; 1004 } 1005} 1006 1007void 1008mp_LinkLost(struct mp *mp, struct datalink *dl) 1009{ 1010 if (mp->seq.min_in == dl->mp.seq) 1011 /* We've lost the link that's holding everything up ! */ 1012 mp_Input(mp, NULL, NULL); 1013} |