Index: ndpsmb.c
===================================================================
--- ndpsmb.c	(revision 123)
+++ ndpsmb.c	(working copy)
@@ -1177,10 +1177,13 @@
 	char fullname[CCHMAXPATH+1] = {0};
 	smbwrp_fileinfo * data;
 	NDPATHELEMENT *pel = ph->fsphNameElem(0);
+    int retry = 0;
 
-	log("NdpFindStart in\n");
 	do
 	{
+    log("NdpFindStart in, retry = %d\n", retry);
+    do
+    {
 		rc = checkconnection(pConn);
 		if (rc)
 		{
@@ -1264,6 +1267,10 @@
 	} while (0);
 
 	log("NdpFindStart <%s> (%s) cnt %d %d %d\n", szPath, path, count, rc, pConn->rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -1372,7 +1379,7 @@
 			}
 		} while (0);
 		log("NdpQueryInfo <%s> (%s) %d %d\n", szPath, path, rc, pConn->rc);
-		retry = rc && !retry;
+        retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
 	} while (retry);
 	
 	return rc;
@@ -1412,8 +1419,11 @@
 	smb_response resp = {0};
 	smbwrp_fileinfo * finfo = (smbwrp_fileinfo *)pConn->mem;
 	char path[CCHMAXPATH+1] = {0};
+    int retry = 0;
 
-	log("NdpSetPathInfo in\n");
+do
+{
+    log("NdpSetPathInfo in, retry = %d\n", retry);
 	do {
 		rc = checkconnection(pConn);
 		if (rc)
@@ -1451,6 +1461,10 @@
 		}
 	} while (0);
 	log("NdpSetPathInfo <%s> (%s) %d %d\n", szPathName, path, rc, pConn->rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -1525,6 +1539,7 @@
 	FEALIST * pFEASrc;
 	NDDATABUF fdata = {0};
 	smbwrp_fileinfo *finfo;
+    int retry = 0;
 
 	if (!pfi || !pfi->pszName || !pFEAList)
 	{
@@ -1544,7 +1559,9 @@
 	finfo = (smbwrp_fileinfo *)fdata.pData;
 	path = finfo->fname;
 
-	log("NdpEAQuery in <%s> %08x %d\n", path, pGEAList, pGEAList ? pGEAList->cbList : 0);
+do
+{
+    log("NdpEAQuery in <%s> %08x %d, retry = %d\n", path, pGEAList, pGEAList ? pGEAList->cbList : 0, retry);
 	do {
 		rc = checkconnection(pConn);
 		if (rc)
@@ -1576,6 +1593,7 @@
 				} break;
 				default :
 				{
+                    if( rc != ERROR_INVALID_PARAMETER || retry )
 					rc = ERROR_EAS_NOT_SUPPORTED;
 				}
 			}
@@ -1586,6 +1604,10 @@
 		}
 	} while (0);
 	log("NdpEAQuery <%s> %d %d %d %d %d\n", pfi->pszName, rc, pFEASrc->cbList, pFEAList->cbList, pConn->rc, resp.rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -1600,9 +1622,8 @@
 	unsigned long action;
 	NDDATABUF fdata = {0};
 	smbwrp_fileinfo *finfo;
+    int retry = 0;
 
-	log("NdpEASet in\n");
-
 	if (!pfi || !pfi->pszName || !pFEAList || pFEAList->cbList <= sizeof(long))
 	{
 		return ERROR_EAS_NOT_SUPPORTED;
@@ -1626,6 +1647,10 @@
 	finfo = (smbwrp_fileinfo *)fdata.pData;
 	path = finfo->fname;
 
+do
+{
+    log("NdpEASet in, retry = %d\n", retry);
+
 	do {
 		rc = checkconnection(pConn);
 		if (rc)
@@ -1645,6 +1670,10 @@
 			rc = pConn->rc ? pConn->rc : (resp.rc ? resp.rc : ERROR_INVALID_PARAMETER);
 		}
 	} while (0);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	log("NdpEASet %d\n", rc);
 	return rc;
 }
@@ -1662,6 +1691,7 @@
 	NDDATABUF fdata = {0};
 	smbwrp_fileinfo *finfo;
 	int easize;
+    int retry = 0;
 
 	if (!pfi || !pulEASize)
 	{
@@ -1689,7 +1719,9 @@
 		return NO_ERROR;
 	}
 
-	log("NdpEASize in <%s> \n", path);
+do
+{
+    log("NdpEASize in <%s>, retry = %d \n", path, retry);
 	do {
 		rc = checkconnection(pConn);
 		if (rc)
@@ -1720,6 +1752,7 @@
 				} break;
 				default :
 				{
+                    if( rc != ERROR_INVALID_PARAMETER || retry )
 					rc = ERROR_EAS_NOT_SUPPORTED;
 				}
 			}
@@ -1727,6 +1760,10 @@
 		*pulEASize = pfealist->cbList;
 	} while (0);
 	log("NdpEASize <%s> %d %d %d %d\n", pfi->pszName, *pulEASize, rc, pConn->rc, resp.rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -1739,8 +1776,11 @@
 	int rc = 0;
 	unsigned long action;
 	char path[CCHMAXPATH+1] = {0};
+    int retry = 0;
 	
-	log("NdpSetCurrentDir in\n");
+do
+{
+    log("NdpSetCurrentDir in, retry = %d\n", retry);
 	do {
 		rc = checkconnection(pConn);
 		if (rc)
@@ -1766,6 +1806,10 @@
 		}
 	} while (0);
 	log("NdpSetCurrentDir <%s> (%s) %d %d\n", szPath, path, rc, pConn->rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -1790,8 +1834,11 @@
 	int rc = 0;
 	unsigned long action;
 	char path[CCHMAXPATH+1] = {0};
+    int retry = 0;
 
-	log("NdpForceDelete in\n");
+do
+{
+    log("NdpForceDelete in, retry = %d\n", retry);
 	do {
 		rc = checkconnection(pConn);
 		if (rc)
@@ -1817,6 +1864,10 @@
 		}
 	} while (0);
 	log("NdpForceDelete <%s> (%s) %d %d\n", szFile, path, rc, pConn->rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -1829,8 +1880,11 @@
 	int rc = 0;
 	unsigned long action;
 	char path[CCHMAXPATH+1] = {0};
+    int retry = 0;
 
-	log("NdpCreateDir in\n");
+do
+{
+    log("NdpCreateDir in, retry = %d\n", retry);
 	do {
 		rc = checkconnection(pConn);
 		if (rc)
@@ -1856,6 +1910,10 @@
 		}
 	} while (0);
 	log("NdpCreateDir <%s> (%s) %d %d\n", szDirName, path, rc, pConn->rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -1868,8 +1926,11 @@
 	int rc = 0;
 	unsigned long action;
 	char path[CCHMAXPATH+1] = {0};
+    int retry = 0;
 
-	log("NdpDeleteDir in\n");
+do
+{
+    log("NdpDeleteDir in, retry = %d\n", retry);
 	do {
 		rc = checkconnection(pConn);
 		if (rc)
@@ -1895,6 +1956,10 @@
 		}
 	} while (0);
 	log("NdpDeleteDir <%s> (%s) %d %d\n", szDir, path, rc, pConn->rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -1909,10 +1974,13 @@
 	char src[CCHMAXPATH+1] = {0};
 	int l1, l2;
 	char * p = szDst;
+    int retry = 0;
 
-	log("NdpMove in\n");
 	do
 	{
+    log("NdpMove in, retry = %d\n", retry);
+    do
+    {
 		rc = checkconnection(pConn);
 		if (rc)
 		{
@@ -1951,6 +2019,9 @@
 	} while (0);
 	log("NdpMove <%s> -> <%s> (%s) %d %d\n", szSrc, szDst, src, rc, pConn->rc);
 
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -1979,8 +2050,11 @@
 	unsigned long action;
 	int rc = 0;
 	char path[CCHMAXPATH+1] = {0};
+    int retry = 0;
 
-	log("smbopen in %d\n", pConn->file.fd);
+do
+{
+    log("smbopen in %d, retry = %d\n", pConn->file.fd, retry);
 	do {
 		if (pConn->file.fd > 0)
 		{
@@ -2035,6 +2109,9 @@
 		log("smbopen NdpFileEASet %d. pFEAList->cbList %d\n", rc1, pFEAList->cbList);
 	}
 
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -2075,8 +2152,11 @@
 	smb_response resp = {0};
 	smbwrp_fileinfo * finfo = (smbwrp_fileinfo *)pConn->mem;
 	char path[CCHMAXPATH+1] = {0};
+    int retry = 0;
 
-	log("NdpSetFileAttribute in\n");
+do
+{
+    log("NdpSetFileAttribute in, retry = %d\n", retry);
 	do {
 		rc = checkconnection(pConn);
 		if (rc)
@@ -2105,6 +2185,10 @@
 		}
 	} while (0);
 	log("NdpSetFileAttribute <%s> (%s) %04x %d %d\n", szFileName, path, usAttr, rc, pConn->rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -2138,8 +2222,11 @@
 	smb_response resp = {0};
 	FILEFINDBUF3 buf;
 	smbwrp_fileinfo * finfo = (smbwrp_fileinfo *)(pConn->mem + sizeof(pConn->file));
+    int retry = 0;
 
-	log("NdpFileQueryInfo in\n");
+do
+{
+    log("NdpFileQueryInfo in, retry = %d\n", retry);
 	do {
 		if (pConn->file.fd < 0 || !*pConn->file.fname)
 		{
@@ -2179,6 +2266,9 @@
 	} while (0);
 	log("NdpFileQueryInfo <%s> %d %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, rc, pConn->rc);
 
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -2191,6 +2281,7 @@
 	smb_request req = {0};
 	smb_response resp = {0};
 	FEALIST * pFEASrc;
+    int retry = 0;
 
 	if (!pFEAList)
 	{
@@ -2201,7 +2292,9 @@
 		return ERROR_EAS_NOT_SUPPORTED;
 	}
 
-	log("NdpFileEAQuery in <%s>/%d pGEAList=%08x\n", pConn->file.fname, pConn->file.fd, pGEAList);
+do
+{
+    log("NdpFileEAQuery in <%s>/%d pGEAList=%08x, retry = %d\n", pConn->file.fname, pConn->file.fd, pGEAList, retry);
 	do {
 		if (pConn->file.fd < 0)
 		{
@@ -2238,6 +2331,7 @@
 				} break;
 				default :
 				{
+                    if( rc != ERROR_INVALID_PARAMETER || retry )
 					rc = ERROR_EAS_NOT_SUPPORTED;
 				}
 			}
@@ -2248,6 +2342,10 @@
 		}
 	} while (0);
 	log("NdpFileEAQuery out <%s>/%d pFEASrc->cbList=%d pFEAList->cbList=%d rc=%d %d %d\n", pConn->file.fname, pConn->file.fd, pFEASrc->cbList, pFEAList->cbList, rc, pConn->rc, resp.rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -2259,9 +2357,8 @@
 	smb_request req = {0};
 	smb_response resp = {0};
 	unsigned long action;
+    int retry = 0;
 
-	log("NdpFileEASet in\n");
-
 	if (!pFEAList || pFEAList->cbList <= sizeof(long))
 	{
 		return ERROR_EAS_NOT_SUPPORTED;
@@ -2275,6 +2372,10 @@
 		return ERROR_NOT_ENOUGH_MEMORY;
 	}
 
+do
+{
+    log("NdpFileEASet in, retry = %d\n", retry);
+
 	do {
 		if (pConn->file.fd < 0)
 		{
@@ -2301,6 +2402,10 @@
 		}
 	} while (0);
 	log("NdpFileEASet %d\n", rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -2314,6 +2419,7 @@
 	smb_response resp = {0};
 	char path[CCHMAXPATH+1] = {0};
 	FEALIST * pfealist;
+    int retry = 0;
 
 	if (!pulEASize)
 	{
@@ -2324,7 +2430,9 @@
 		return ERROR_EAS_NOT_SUPPORTED;
 	}
 
-	log("NdpFileEASize in <%s>/%d \n", pConn->file.fname, pConn->file.fd);
+do
+{
+    log("NdpFileEASize in <%s>/%d, retry = %d\n", pConn->file.fname, pConn->file.fd, retry);
 	do {
 		if (pConn->file.fd < 0)
 		{
@@ -2360,6 +2468,7 @@
 				} break;
 				default :
 				{
+                    if( rc != ERROR_INVALID_PARAMETER || retry )
 					rc = ERROR_EAS_NOT_SUPPORTED;
 				}
 			}
@@ -2367,6 +2476,10 @@
 		*pulEASize = pfealist->cbList;
 	} while (0);
 	log("NdpFileEASize %d %d %d %d\n", *pulEASize, rc, pConn->rc, resp.rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -2417,8 +2530,11 @@
 	unsigned long action;
 	smb_request req = {0};
 	smb_response resp = {0};
+    int retry = 0;
 
-	log("NdpFileSetFilePtrl in\n");
+do
+{
+    log("NdpFileSetFilePtrl in, retry = %d\n", retry);
 	do {
 		if (pConn->file.fd < 0)
 		{
@@ -2451,6 +2567,9 @@
 	} while (0);
 	log("NdpFileSetFilePtrL <%s> %lld %lu %lld %d %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, llOffset, ulMethod, *pllActual, rc, pConn->rc);
 
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -2471,8 +2590,11 @@
 	unsigned long action;
 	smb_request req = {0};
 	smb_response resp = {0};
+    int retry = 0;
 
-	log("NdpFileClose in %d <%s>\n", pConn->file.fd, pConn->file.fd < 0 ? "!null!" : pConn->file.fname);
+do
+{
+    log("NdpFileClose in %d <%s>, retry = %d\n", pConn->file.fd, pConn->file.fd < 0 ? "!null!" : pConn->file.fname, retry);
 
 	do {
 		if (pConn->file.fd < 0)
@@ -2503,6 +2625,10 @@
 		}
 	} while (0);
 	log("NdpFileClose %d %d %d\n", pConn->file.fd, rc, pConn->rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	pConn->file.fd = -1;
 	return rc;
 }
@@ -2529,8 +2655,11 @@
 	unsigned long action;
 	smb_request req = {0};
 	smb_response resp = {0};
+    int retry = 0;
 
-	log("NdpFileNewSizeL in\n");
+do
+{
+    log("NdpFileNewSizeL in, retry = %d\n", retry);
 	do {
 		if (pConn->file.fd < 0)
 		{
@@ -2562,6 +2691,10 @@
 		}
 	} while (0);
 	log("NdpFileNewSizeL <%s> %lld %d %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, llLen, rc, pConn->rc);
+
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -2575,8 +2708,11 @@
 	unsigned long action;
 	smb_request req = {0};
 	smb_response resp = {0};
+    int retry = 0;
 
-	log("NdpFileRead in\n");
+do
+{
+    log("NdpFileRead in, retry = %d\n", retry);
 //	log("NdpFileRead <%s> %lu\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulRead);
 
 	do {
@@ -2619,6 +2755,9 @@
 	} while (0);
 	log("NdpFileRead <%s> %lu %lu %d %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulRead, *pulActual, rc, pConn->rc);
 
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
 
@@ -2632,8 +2771,11 @@
 	unsigned long action;
 	smb_request req = {0};
 	smb_response resp = {0};
+    int retry = 0;
 
-	log("NdpFileWrite in\n");
+do
+{
+    log("NdpFileWrite in, retry = %d\n", retry);
 	do {
 		if (pConn->file.fd < 0)
 		{
@@ -2674,5 +2816,8 @@
 	} while (0);
 	log("NdpFileWrite <%s> %lu %lu %d %d\n", pConn->file.fd < 0 ? "!null!" : pConn->file.fname, ulWrite, *pulActual, rc, pConn->rc);
 
+    retry = ( rc == ERROR_INVALID_PARAMETER ) && !retry;
+} while( retry );
+
 	return rc;
 }
