void cm_QueueBKGRequest(cm_scache_t *scp, cm_bkgProc_t *procp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, cm_user_t *userp) { cm_bkgRequest_t *rp; rp = malloc(sizeof(*rp)); memset(rp, 0, sizeof(*rp)); cm_HoldSCache(scp); rp->scp = scp; cm_HoldUser(userp); rp->userp = userp; rp->procp = procp; rp->p1 = p1; rp->p2 = p2; rp->p3 = p3; rp->p4 = p4; lock_ObtainWrite(&cm_daemonLock); cm_bkgQueueCount++; osi_QAdd((osi_queue_t **) &cm_bkgListp, &rp->q); if (!cm_bkgListEndp) cm_bkgListEndp = rp; lock_ReleaseWrite(&cm_daemonLock); osi_Wakeup((LONG_PTR) &cm_bkgListp); }
void cm_QueueBKGRequest(cm_scache_t *scp, cm_bkgProc_t *procp, afs_uint32 p1, afs_uint32 p2, afs_uint32 p3, afs_uint32 p4, cm_user_t *userp, cm_req_t *reqp) { cm_bkgRequest_t *rp, *rpq; afs_uint32 daemonID; int duplicate = 0; rp = malloc(sizeof(*rp)); memset(rp, 0, sizeof(*rp)); cm_HoldSCache(scp); rp->scp = scp; cm_HoldUser(userp); rp->userp = userp; rp->procp = procp; rp->p1 = p1; rp->p2 = p2; rp->p3 = p3; rp->p4 = p4; rp->req = *reqp; /* Use separate queues for fetch and store operations */ daemonID = scp->fid.hash % (cm_nDaemons/2) * 2; if (procp == cm_BkgStore) daemonID++; lock_ObtainWrite(&cm_daemonLockp[daemonID]); /* Check to see if this is a duplicate request */ for (rpq = cm_bkgListpp[daemonID]; rpq; rpq = (cm_bkgRequest_t *) osi_QNext(&rpq->q)) { if ( rpq->p1 == p1 && rpq->p3 == p3 && rpq->procp == procp && rpq->p2 == p2 && rpq->p4 == p4 && rpq->scp == scp && rpq->userp == userp) { /* found a duplicate; update request with latest info */ duplicate = 1; break; } } if (!duplicate) { cm_bkgQueueCountp[daemonID]++; osi_QAddH((osi_queue_t **) &cm_bkgListpp[daemonID], (osi_queue_t **)&cm_bkgListEndpp[daemonID], &rp->q); } lock_ReleaseWrite(&cm_daemonLockp[daemonID]); if (duplicate) { cm_ReleaseSCache(scp); cm_ReleaseUser(userp); free(rp); } else { osi_Wakeup((LONG_PTR) &cm_bkgListpp[daemonID]); } }
/** Setup a smb_fid:: structure for RPC \note Obtains fidp->mx */ afs_int32 smb_SetupRPCFid(smb_fid_t * fidp, const clientchar_t * _epnamep, unsigned short * file_type, unsigned short * device_state) { smb_rpc_t *rpcp; afs_int32 code = 0; const clientchar_t * epnamep; epnamep = cm_ClientStrChr(_epnamep, _C('\\')); if (epnamep == NULL) epnamep = _epnamep; else epnamep = cm_ClientCharNext(epnamep); lock_ObtainMutex(&fidp->mx); fidp->flags |= SMB_FID_RPC; fidp->scp = &cm_data.fakeSCache; cm_HoldSCache(fidp->scp); if (fidp->rpcp == NULL) { rpcp = malloc(sizeof(*rpcp)); memset(rpcp, 0, sizeof(*rpcp)); fidp->rpcp = rpcp; rpcp->fidp = fidp; } else { rpcp = fidp->rpcp; } code = smb_RPC_SetupEndpointByname(rpcp, epnamep); lock_ReleaseMutex(&fidp->mx); if (code == 0) { *file_type = SMB_FILETYPE_MESSAGE_MODE_PIPE; *device_state =((0xff) | /* instance count */ SMB_DEVICESTATE_READMSGFROMPIPE | SMB_DEVICESTATE_MESSAGEMODEPIPE | SMB_DEVICESTATE_PIPECLIENTEND); } return code; }