Fixes to:

1) retain the buffered/unbuffered line specific details across save/restore
 2) retain modem control outgoing bits (CTS and DTR) accross line resets which may occur due to carrier/connection loss.
 3) change the behavior which sends  the prior contents of the transmit buffer on a line reconnect to only happen for buffered telnet lines.
 4) avoid crash in SHOW MULTIPLEXER output when only specific lines have been attached instead of
This commit is contained in:
Mark Pizzolato 2013-05-27 15:14:54 -07:00
parent 1eb15fc917
commit f30d43209e

View file

@ -436,12 +436,14 @@ lp->tsta = 0; /* init telnet state */
lp->xmte = 1; /* enable transmit */ lp->xmte = 1; /* enable transmit */
lp->dstb = 0; /* default bin mode */ lp->dstb = 0; /* default bin mode */
lp->rxbpr = lp->rxbpi = lp->rxcnt = 0; /* init receive indexes */ lp->rxbpr = lp->rxbpi = lp->rxcnt = 0; /* init receive indexes */
if (!lp->txbfd) /* if not buffered */ if (!lp->txbfd || lp->notelnet) /* if not buffered telnet */
lp->txbpr = lp->txbpi = lp->txcnt = 0; /* init transmit indexes */ lp->txbpr = lp->txbpi = lp->txcnt = 0; /* init transmit indexes */
memset (lp->rbr, 0, sizeof(lp->rbr)); /* clear break status array */ memset (lp->rbr, 0, sizeof(lp->rbr)); /* clear break status array */
lp->txdrp = 0; lp->txdrp = 0;
if (lp->modem_control) if (lp->modem_control) {
lp->modembits = TMXR_MDM_CTS | TMXR_MDM_DSR; lp->modembits &= ~TMXR_MDM_INCOMING;
lp->modembits |= TMXR_MDM_CTS | TMXR_MDM_DSR;
}
if (!lp->mp->buffered) { if (!lp->mp->buffered) {
lp->txbfd = 0; lp->txbfd = 0;
lp->txbsz = TMXR_MAXBUF; lp->txbsz = TMXR_MAXBUF;
@ -695,7 +697,7 @@ static char *growstring(char **string, size_t growth)
return *string + strlen(*string); return *string + strlen(*string);
} }
static char *_mux_attach_string(char *old, TMXR *mp) static char *tmxr_mux_attach_string(char *old, TMXR *mp)
{ {
char* tptr = NULL; char* tptr = NULL;
int32 i; int32 i;
@ -767,6 +769,10 @@ if (lp->destination || lp->port || lp->txlogname) {
sprintf (growstring(&tptr, 32), "Line=%d", (int)(lp-lp->mp->ldsc)); sprintf (growstring(&tptr, 32), "Line=%d", (int)(lp-lp->mp->ldsc));
if (lp->modem_control != lp->mp->modem_control) if (lp->modem_control != lp->mp->modem_control)
sprintf (growstring(&tptr, 32), ",%s", lp->modem_control ? "Modem" : "NoModem"); sprintf (growstring(&tptr, 32), ",%s", lp->modem_control ? "Modem" : "NoModem");
if (lp->txbfd && (lp->txbsz != lp->mp->buffered))
sprintf (growstring(&tptr, 32), ",Buffered=%d", lp->txbsz);
if (!lp->txbfd && (lp->mp->buffered > 0))
sprintf (growstring(&tptr, 32), ",UnBuffered");
if (lp->destination) { if (lp->destination) {
if (lp->serport) { if (lp->serport) {
char portname[CBUFSIZE]; char portname[CBUFSIZE];
@ -1091,7 +1097,7 @@ if ((lp->destination) && (!lp->serport)) {
tmxr_init_line (lp); /* initialize line state */ tmxr_init_line (lp); /* initialize line state */
if (lp->mp->uptr) { if (lp->mp->uptr) {
/* Revise the unit's connect string to reflect the current attachments */ /* Revise the unit's connect string to reflect the current attachments */
lp->mp->uptr->filename = _mux_attach_string (lp->mp->uptr->filename, lp->mp); lp->mp->uptr->filename = tmxr_mux_attach_string (lp->mp->uptr->filename, lp->mp);
/* No connections or listeners exist, then we're equivalent to being fully detached. We should reflect that */ /* No connections or listeners exist, then we're equivalent to being fully detached. We should reflect that */
if (lp->mp->uptr->filename == NULL) if (lp->mp->uptr->filename == NULL)
tmxr_detach (lp->mp, lp->mp->uptr); tmxr_detach (lp->mp, lp->mp->uptr);
@ -1272,7 +1278,7 @@ else {
r = SCPE_OK; r = SCPE_OK;
} }
if (r == SCPE_OK) /* Record port state for proper restore */ if (r == SCPE_OK) /* Record port state for proper restore */
lp->mp->uptr->filename = _mux_attach_string (lp->mp->uptr->filename, lp->mp); lp->mp->uptr->filename = tmxr_mux_attach_string (lp->mp->uptr->filename, lp->mp);
return r; return r;
} }
@ -1342,7 +1348,7 @@ for (i = 0; i < mp->lines; i++) { /* loop thru lines */
TMXR_MAXBUF - lp->rxbpi); TMXR_MAXBUF - lp->rxbpi);
if (nbytes < 0) { /* line error? */ if (nbytes < 0) { /* line error? */
if (!lp->txbfd) if (!lp->txbfd || lp->notelnet)
lp->txbpi = lp->txbpr = 0; /* Drop the data we already know we can't send */ lp->txbpi = lp->txbpr = 0; /* Drop the data we already know we can't send */
tmxr_close_ln (lp); /* disconnect line */ tmxr_close_ln (lp); /* disconnect line */
} }
@ -1493,8 +1499,8 @@ return (lp->rxbpi - lp->rxbpr + ((lp->rxbpi < lp->rxbpr)? TMXR_MAXBUF: 0));
t_stat tmxr_putc_ln (TMLN *lp, int32 chr) t_stat tmxr_putc_ln (TMLN *lp, int32 chr)
{ {
if ((lp->conn == FALSE) && /* no conn & not buffered? */ if ((lp->conn == FALSE) && /* no conn & not buffered telnet? */
(!lp->txbfd)) { (!lp->txbfd || lp->notelnet)) {
++lp->txdrp; /* lost */ ++lp->txdrp; /* lost */
return SCPE_LOST; return SCPE_LOST;
} }
@ -2783,7 +2789,7 @@ r = tmxr_open_master (mp, cptr); /* open master socket */
if (r != SCPE_OK) /* error? */ if (r != SCPE_OK) /* error? */
return r; return r;
mp->uptr = uptr; /* save unit for polling */ mp->uptr = uptr; /* save unit for polling */
uptr->filename = _mux_attach_string (uptr->filename, mp);/* save */ uptr->filename = tmxr_mux_attach_string (uptr->filename, mp);/* save */
uptr->flags = uptr->flags | UNIT_ATT; /* no more errors */ uptr->flags = uptr->flags | UNIT_ATT; /* no more errors */
if ((mp->lines > 1) || if ((mp->lines > 1) ||
((mp->master == 0) && ((mp->master == 0) &&
@ -2828,9 +2834,12 @@ else {
for (i=0; i<tmxr_open_device_count; ++i) { for (i=0; i<tmxr_open_device_count; ++i) {
TMXR *mp = tmxr_open_devices[i]; TMXR *mp = tmxr_open_devices[i];
TMLN *lp; TMLN *lp;
char *attach;
fprintf(st, "Multiplexer device: %s", mp->dptr->name); fprintf(st, "Multiplexer device: %s, ", mp->dptr->name);
fprintf(st, ", attached to %s, ", mp->uptr->filename); attach = tmxr_mux_attach_string (NULL, mp);
fprintf(st, "attached to %s, ", attach);
free (attach);
if (mp->lines > 1) { if (mp->lines > 1) {
tmxr_show_lines(st, NULL, 0, mp); tmxr_show_lines(st, NULL, 0, mp);
fprintf(st, ", "); fprintf(st, ", ");
@ -3427,7 +3436,7 @@ if (lp->txlog == NULL) { /* error? */
free (lp->txlogname); /* free buffer */ free (lp->txlogname); /* free buffer */
return SCPE_OPENERR; return SCPE_OPENERR;
} }
lp->mp->uptr->filename = _mux_attach_string (lp->mp->uptr->filename, lp->mp); lp->mp->uptr->filename = tmxr_mux_attach_string (lp->mp->uptr->filename, lp->mp);
return SCPE_OK; return SCPE_OK;
} }
@ -3450,7 +3459,7 @@ if (lp->txlog) { /* logging? */
lp->txlog = NULL; lp->txlog = NULL;
lp->txlogname = NULL; lp->txlogname = NULL;
} }
lp->mp->uptr->filename = _mux_attach_string (lp->mp->uptr->filename, lp->mp); lp->mp->uptr->filename = tmxr_mux_attach_string (lp->mp->uptr->filename, lp->mp);
return SCPE_OK; return SCPE_OK;
} }