PERFORCE change 125435 for review
Fredrik Lindberg
fli at FreeBSD.org
Mon Aug 20 10:25:13 PDT 2007
http://perforce.freebsd.org/chv.cgi?CH=125435
Change 125435 by fli at fli_nexus on 2007/08/20 17:24:29
- Change how resources are sent.
- Code to send record names was broken.
- Some other minor fixes.
Affected files ...
.. //depot/projects/soc2007/fli-mdns_sd/mdnsd/clisrv.c#8 edit
Differences ...
==== //depot/projects/soc2007/fli-mdns_sd/mdnsd/clisrv.c#8 (text+ko) ====
@@ -993,7 +993,7 @@
if (len < miinl->miinl_ilen)
return (MIE_IVAL);
- ident = malloc(miinl->miinl_ilen + 0);
+ ident = malloc(miinl->miinl_ilen + 1);
if (ident == NULL)
return (MIE_INTE);
memcpy(ident, p, miinl->miinl_ilen);
@@ -1020,9 +1020,6 @@
goto out;
}
- miin.miin_ifidx = mif->mif_index;
- miin.miin_zero = 0;
-
RW_UNLOCK(g, g_lock);
IPC_SETHDR(&rmih, mih->mih_id, MIM_IDENT_NAME, 0);
@@ -1032,23 +1029,26 @@
iov[1].iov_len = sizeof(struct mipc_dbi_name);
iov[2].iov_base = ident;
iov[2].iov_len = miinl->miinl_ilen;
+
miin.miin_ilen = miinl->miinl_ilen;
+ miin.miin_ifidx = mif->mif_index;
+ miin.miin_zero = 0;
for (i = 0; i < namlen; i++) {
rmih.mih_msglen = sizeof(struct mipc_head) +
sizeof(struct mipc_dbi_name) + miinl->miinl_ilen;
- len = wcslen(dn[i].dn_name);
+ nlen = wcslen(dn[i].dn_name);
iov[3].iov_base = dn[i].dn_name;
- iov[3].iov_len = len * sizeof(wchar_t);
- rmih.mih_msglen += nlen;
+ iov[3].iov_len = nlen * sizeof(wchar_t);
+ rmih.mih_msglen += (nlen * sizeof(wchar_t));
miin.miin_len = nlen;
if (dn[i].dn_ename != NULL) {
- len = wcslen(dn[i].dn_ename);
+ nlen = wcslen(dn[i].dn_ename);
iov[4].iov_base = dn[i].dn_ename;
- iov[4].iov_len = len * sizeof(wchar_t);
- rmih.mih_msglen += nlen;
+ iov[4].iov_len = nlen * sizeof(wchar_t);
+ rmih.mih_msglen += (nlen * sizeof(wchar_t));
miin.miin_elen = nlen;
}
else {
@@ -1265,7 +1265,7 @@
struct dbr_resource *dres;
struct mipc_head rmih;
struct mipc_dbi_res_get mirg;
- struct iovec iov[6];
+ struct iovec iov[5];
if (len < sizeof(struct mipc_dbi_res_list))
return (MIE_IVAL);
@@ -1299,30 +1299,28 @@
if (dres == NULL)
goto out;
+ dprintf(DEBUG_CS, "Request to list resources on identifier %s, "
+ "csc=%x, ifidx=%d", ident, csc, mirl->mirl_ifidx);
+
IPC_SETHDR(&rmih, mih->mih_id, MIM_IDENT_RES, 0);
iov[0].iov_base = &rmih;
iov[0].iov_len = sizeof(struct mipc_head);
iov[1].iov_base = &mirg;
iov[1].iov_len = sizeof(struct mipc_dbi_res_get);
- mirg.mirg_zero = 0;
for (i = 0; i < reslen; i++) {
- mih->mih_msglen = sizeof(struct mipc_head) +
+ rmih.mih_msglen = sizeof(struct mipc_head) +
sizeof(struct mipc_dbi_res_get);
- iov[2].iov_base = dres[i].dres_name;
- tmplen = wcslen(dres[i].dres_name) * sizeof(wchar_t);
+ iov[2].iov_base = dres[i].dres_res;
+ mirg.mirg_len = wcslen(dres[i].dres_res);
+ tmplen = mirg.mirg_len * sizeof(wchar_t);
iov[2].iov_len = tmplen;
- mih->mih_msglen += tmplen;
+ rmih.mih_msglen += tmplen;
- iov[3].iov_base = dres[i].dres_res;
- tmplen = wcslen(dres[i].dres_res) * sizeof(wchar_t);
- iov[3].iov_len = tmplen;
- mih->mih_msglen += tmplen;
-
- iov[4].iov_base = dres[i].dres_data;
- iov[4].iov_len = dres[i].dres_len;
- mih->mih_msglen += dres[i].dres_len;
+ iov[3].iov_base = dres[i].dres_data;
+ iov[3].iov_len = dres[i].dres_len;
+ rmih.mih_msglen += dres[i].dres_len;
mirg.mirg_elen = dres[i].dres_len;
mirg.mirg_class = dres[i].dres_class;
@@ -1330,18 +1328,18 @@
mirg.mirg_ttl = dres[i].dres_ttl;
if (dres[i].dres_resptr != NULL) {
- iov[5].iov_base = dres[i].dres_resptr;
+ iov[4].iov_base = dres[i].dres_resptr;
tmplen = strlen(dres[i].dres_resptr);
- iov[5].iov_len = tmplen;
+ iov[4].iov_len = tmplen;
mirg.mirg_ilen = tmplen;
- mih->mih_msglen += tmplen;
+ rmih.mih_msglen += tmplen;
}
else {
mirg.mirg_ilen = 0;
- iov[5].iov_base = NULL;
- iov[5].iov_len = 0;
+ iov[4].iov_base = NULL;
+ iov[4].iov_len = 0;
}
- writev(csc->csc_sock, iov, 6);
+ writev(csc->csc_sock, iov, 5);
}
RW_UNLOCK(g, g_lock);
@@ -1550,6 +1548,7 @@
iov[0].iov_base = &mih;
iov[0].iov_len = sizeof(struct mipc_head);
writev(csc->csc_sock, iov, 1);
+ dprintf(DEBUG_CS, "Ack sent to client csc=%x, id=%d", csc, id);
}
More information about the p4-projects
mailing list