Log link name changes correctly.
This commit is contained in:
parent
1bc9b5ba84
commit
84917b87ba
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: bundle.c,v 1.1.2.73 1998/05/06 18:49:36 brian Exp $
|
||||
* $Id: bundle.c,v 1.1.2.74 1998/05/06 18:50:02 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -1265,14 +1265,25 @@ bundle_ReceiveDatalink(struct bundle *bundle, int s, struct sockaddr_un *sun)
|
||||
ndl = iov2datalink(bundle, iov, &niov, sizeof iov / sizeof *iov, link_fd);
|
||||
if (ndl) {
|
||||
/* Make sure the name is unique ! */
|
||||
char *oname;
|
||||
|
||||
oname = NULL;
|
||||
do {
|
||||
for (dl = bundle->links; dl; dl = dl->next)
|
||||
if (!strcasecmp(ndl->name, dl->name)) {
|
||||
datalink_Rename(ndl);
|
||||
break;
|
||||
if (oname)
|
||||
free(datalink_NextName(ndl));
|
||||
else
|
||||
oname = datalink_NextName(ndl);
|
||||
break; /* Keep renaming 'till we have no conflicts */
|
||||
}
|
||||
} while (dl);
|
||||
|
||||
if (oname) {
|
||||
log_Printf(LogPHASE, "Rename link %s to %s\n", oname, ndl->name);
|
||||
free(oname);
|
||||
}
|
||||
|
||||
ndl->next = bundle->links;
|
||||
bundle->links = ndl;
|
||||
bundle_GenPhysType(bundle);
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: datalink.c,v 1.1.2.54 1998/05/02 21:57:44 brian Exp $
|
||||
* $Id: datalink.c,v 1.1.2.55 1998/05/06 18:49:39 brian Exp $
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
@ -1016,11 +1016,11 @@ datalink2iov(struct datalink *dl, struct iovec *iov, int *niov, int maxiov)
|
||||
return link_fd;
|
||||
}
|
||||
|
||||
void
|
||||
datalink_Rename(struct datalink *dl)
|
||||
char *
|
||||
datalink_NextName(struct datalink *dl)
|
||||
{
|
||||
int f, n;
|
||||
char *name;
|
||||
char *name, *oname;
|
||||
|
||||
n = strlen(dl->name);
|
||||
name = (char *)malloc(n+3);
|
||||
@ -1029,7 +1029,7 @@ datalink_Rename(struct datalink *dl)
|
||||
break;
|
||||
n = sprintf(name, "%.*s-", dl->name[f] == '-' ? f : f + 1, dl->name);
|
||||
sprintf(name + n, "%d", atoi(dl->name + f + 1) + 1);
|
||||
log_Printf(LogPHASE, "Rename link %s to %s\n", dl->name, name);
|
||||
free(dl->name);
|
||||
oname = dl->name;
|
||||
dl->physical->link.name = dl->name = name;
|
||||
return oname;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: datalink.h,v 1.1.2.21 1998/05/01 19:24:24 brian Exp $
|
||||
* $Id: datalink.h,v 1.1.2.22 1998/05/02 21:57:45 brian Exp $
|
||||
*/
|
||||
|
||||
#define DATALINK_CLOSED (0)
|
||||
@ -123,4 +123,4 @@ extern int datalink_Show(struct cmdargs const *);
|
||||
extern int datalink_SetRedial(struct cmdargs const *);
|
||||
extern int datalink_SetReconnect(struct cmdargs const *);
|
||||
extern const char *datalink_State(struct datalink *);
|
||||
extern void datalink_Rename(struct datalink *);
|
||||
extern char *datalink_NextName(struct datalink *);
|
||||
|
Loading…
x
Reference in New Issue
Block a user