コード例 #1
0
  /**
   * Fail any deferred requests that are attached to this oplock, and clear the deferred list
   *
   * @return int Number of deferred requests that were failed
   */
  public int failDeferredRequests() {

    // Check if there are any deferred requests

    if (m_deferredRequests == null) return 0;

    int failCnt = 0;

    synchronized (m_deferredRequests) {
      for (DeferredRequest deferReq : m_deferredRequests) {

        // Get the deferred session/packet details

        SMBSrvSession sess = deferReq.getDeferredSession();
        SMBSrvPacket pkt = deferReq.getDeferredPacket();

        try {

          // Return an error for the deferred file open request

          if (sess.sendAsyncErrorResponseSMB(pkt, SMBStatus.NTAccessDenied, SMBStatus.NTErr)
              == true) {

            // Update the failed request count

            failCnt++;

            // DEBUG

            if (Debug.EnableDbg && sess.hasDebug(SMBSrvSession.DBG_OPLOCK))
              Debug.println("Oplock break timeout, oplock=" + this);
          } else if (Debug.EnableDbg && sess.hasDebug(SMBSrvSession.DBG_OPLOCK))
            Debug.println("Failed to send open reject, oplock break timed out, oplock=" + this);
        } catch (IOException ex) {

        } finally {

          // Make sure the packet is released back to the memory pool

          if (pkt != null) sess.getPacketPool().releasePacket(pkt);
        }
      }

      // Clear the deferred request list

      m_deferredRequests.clear();
    }

    // Return the count of failed requests

    return failCnt;
  }
コード例 #2
0
  /**
   * Requeue deferred requests to the thread pool for processing, oplock has been released
   *
   * @return int Number of deferred requests requeued
   */
  public int requeueDeferredRequests() {

    // Check if there are any deferred requests

    if (m_deferredRequests == null) return 0;

    int requeueCnt = 0;

    synchronized (m_deferredRequests) {
      for (DeferredRequest deferReq : m_deferredRequests) {

        // Get the deferred session/packet details

        SMBSrvSession sess = deferReq.getDeferredSession();
        SMBSrvPacket pkt = deferReq.getDeferredPacket();

        // DEBUG

        if (Debug.EnableDbg && sess.hasDebug(SMBSrvSession.DBG_OPLOCK))
          Debug.println(
              "Release oplock, queued deferred request to thread pool sess="
                  + sess.getUniqueId()
                  + ", pkt="
                  + pkt);

        try {

          // Queue the deferred request to the thread pool for processing

          sess.getThreadPool().queueRequest(new CIFSThreadRequest(sess, pkt));
        } catch (Throwable ex) {

          // Failed to queue the request to the thread pool, release the deferred packet back to the
          // memory pool

          sess.getPacketPool().releasePacket(pkt);
        }
      }

      // Clear the deferred request list

      m_deferredRequests.clear();
    }

    // Return the count of requeued requests

    return requeueCnt;
  }
コード例 #3
0
  /** Update the deferred packet lease time(s) as we wait for an oplock break or timeout */
  public void updateDeferredPacketLease() {

    // Check if there are deferred requests

    if (m_deferredRequests != null) {

      synchronized (m_deferredRequests) {

        // Update the packet lease time for all deferred packets to prevent them timing out

        long newLeaseTime = System.currentTimeMillis() + CIFSPacketPool.CIFSLeaseTime;

        for (DeferredRequest deferReq : m_deferredRequests) {
          deferReq.getDeferredPacket().setLeaseTime(newLeaseTime);
        }
      }
    }
  }