Пример #1
0
 private void checkReceived() {
   OnDemandData onDemandData;
   synchronized (aClass19_1370) {
     onDemandData = (OnDemandData) aClass19_1370.popHead();
   }
   while (onDemandData != null) {
     waiting = true;
     byte abyte0[] = null;
     if (clientInstance.caches[0] != null)
       abyte0 = clientInstance.caches[onDemandData.dataType + 1].decompress(onDemandData.id);
     if (!crcMatches(
         versions[onDemandData.dataType][onDemandData.id],
         crcs[onDemandData.dataType][onDemandData.id],
         abyte0)) abyte0 = null;
     synchronized (aClass19_1370) {
       if (abyte0 == null) {
         aClass19_1368.insertHead(onDemandData);
       } else {
         onDemandData.buffer = abyte0;
         synchronized (aClass19_1358) {
           aClass19_1358.insertHead(onDemandData);
         }
       }
       onDemandData = (OnDemandData) aClass19_1370.popHead();
     }
   }
 }
Пример #2
0
  public OnDemandData getNextNode() {
    OnDemandData onDemandData;
    synchronized (aClass19_1358) {
      onDemandData = (OnDemandData) aClass19_1358.popHead();
    }
    if (onDemandData == null) return null;
    synchronized (nodeSubList) {
      onDemandData.unlist();
    }
    if (onDemandData.buffer == null) return onDemandData;
    int i = 0;
    try {
      GZIPInputStream gzipinputstream =
          new GZIPInputStream(new ByteArrayInputStream(onDemandData.buffer));
      do {
        if (i == gzipInputBuffer.length) throw new RuntimeException("buffer overflow!");
        int k = gzipinputstream.read(gzipInputBuffer, i, gzipInputBuffer.length - i);
        if (k == -1) break;
        i += k;
      } while (true);
    } catch (IOException _ex) {
      throw new RuntimeException("error unzipping");
    }
    onDemandData.buffer = new byte[i];
    System.arraycopy(gzipInputBuffer, 0, onDemandData.buffer, 0, i);

    return onDemandData;
  }
Пример #3
0
 public void passiveRequest(int id, int type) {
   if (clientInstance.caches[0] == null) return;
   if (versions[type][id] == 0) return;
   if (filePriorities[type][id] == 0) return;
   if (highestPriority == 0) return;
   OnDemandData onDemandData = new OnDemandData();
   onDemandData.dataType = type;
   onDemandData.id = id;
   onDemandData.incomplete = false;
   synchronized (passiveRequests) {
     passiveRequests.insertHead(onDemandData);
   }
 }
Пример #4
0
  private void method568() {
    while (uncompletedCount == 0 && completedCount < 10) {
      if (highestPriority == 0) break;
      OnDemandData onDemandData;
      synchronized (passiveRequests) {
        onDemandData = (OnDemandData) passiveRequests.popHead();
      }
      while (onDemandData != null) {
        if (filePriorities[onDemandData.dataType][onDemandData.id] != 0) {
          filePriorities[onDemandData.dataType][onDemandData.id] = 0;
          requested.insertHead(onDemandData);
          closeRequest(onDemandData);
          waiting = true;
          if (filesLoaded < totalFiles) filesLoaded++;
          statusString = "Loading extra files - " + (filesLoaded * 100) / totalFiles + "%";
          completedCount++;
          if (completedCount == 10) return;
        }
        synchronized (passiveRequests) {
          onDemandData = (OnDemandData) passiveRequests.popHead();
        }
      }
      for (int j = 0; j < 4; j++) {
        byte abyte0[] = filePriorities[j];
        int k = abyte0.length;
        for (int l = 0; l < k; l++)
          if (abyte0[l] == highestPriority) {
            abyte0[l] = 0;
            OnDemandData onDemandData_1 = new OnDemandData();
            onDemandData_1.dataType = j;
            onDemandData_1.id = l;
            onDemandData_1.incomplete = false;
            requested.insertHead(onDemandData_1);
            closeRequest(onDemandData_1);
            waiting = true;
            if (filesLoaded < totalFiles) filesLoaded++;
            statusString = "Loading extra files - " + (filesLoaded * 100) / totalFiles + "%";
            completedCount++;
            if (completedCount == 10) return;
          }
      }

      highestPriority--;
    }
  }
Пример #5
0
  public void request(int i, int j) {
    if (i < 0 || i > versions.length || j < 0 || j > versions[i].length) return;
    if (versions[i][j] == 0) return;
    synchronized (nodeSubList) {
      for (OnDemandData onDemandData = (OnDemandData) nodeSubList.reverseGetFirst();
          onDemandData != null;
          onDemandData = (OnDemandData) nodeSubList.reverseGetNext())
        if (onDemandData.dataType == i && onDemandData.id == j) return;

      OnDemandData onDemandData_1 = new OnDemandData();
      onDemandData_1.dataType = i;
      onDemandData_1.id = j;
      onDemandData_1.incomplete = true;
      synchronized (aClass19_1370) {
        aClass19_1370.insertHead(onDemandData_1);
      }
      nodeSubList.push(onDemandData_1);
    }
  }
Пример #6
0
  private void readData() {
    try {
      int j = inputStream.available();
      if (expectedSize == 0 && j >= 6) {
        waiting = true;
        for (int k = 0; k < 6; k += inputStream.read(ioBuffer, k, 6 - k)) ;
        int l = ioBuffer[0] & 0xff;
        int j1 = ((ioBuffer[1] & 0xff) << 8) + (ioBuffer[2] & 0xff);
        int l1 = ((ioBuffer[3] & 0xff) << 8) + (ioBuffer[4] & 0xff);
        int i2 = ioBuffer[5] & 0xff;
        current = null;
        for (OnDemandData onDemandData = (OnDemandData) requested.peekLast();
            onDemandData != null;
            onDemandData = (OnDemandData) requested.reverseGetNext()) {
          if (onDemandData.dataType == l && onDemandData.id == j1) current = onDemandData;
          if (current != null) onDemandData.loopCycle = 0;
        }

        if (current != null) {
          loopCycle = 0;
          if (l1 == 0) {
            signlink.reporterror("Rej: " + l + "," + j1);
            current.buffer = null;
            if (current.incomplete)
              synchronized (aClass19_1358) {
                aClass19_1358.insertHead(current);
              }
            else current.unlink();
            current = null;
          } else {
            if (current.buffer == null && i2 == 0) current.buffer = new byte[l1];
            if (current.buffer == null && i2 != 0) throw new IOException("missing start of file");
          }
        }
        completedSize = i2 * 500;
        expectedSize = 500;
        if (expectedSize > l1 - i2 * 500) expectedSize = l1 - i2 * 500;
      }
      if (expectedSize > 0 && j >= expectedSize) {
        waiting = true;
        byte abyte0[] = ioBuffer;
        int i1 = 0;
        if (current != null) {
          abyte0 = current.buffer;
          i1 = completedSize;
        }
        for (int k1 = 0;
            k1 < expectedSize;
            k1 += inputStream.read(abyte0, k1 + i1, expectedSize - k1)) ;
        if (expectedSize + completedSize >= abyte0.length && current != null) {
          if (clientInstance.caches[0] != null)
            clientInstance.caches[current.dataType + 1].put(abyte0.length, abyte0, current.id);
          if (!current.incomplete && current.dataType == 3) {
            current.incomplete = true;
            current.dataType = 93;
          }
          if (current.incomplete)
            synchronized (aClass19_1358) {
              aClass19_1358.insertHead(current);
            }
          else current.unlink();
        }
        expectedSize = 0;
      }
    } catch (IOException ioexception) {
      try {
        socket.close();
      } catch (Exception _ex) {
      }
      socket = null;
      inputStream = null;
      outputStream = null;
      expectedSize = 0;
    }
  }
Пример #7
0
  @Override
  public void run() {
    try {
      while (running) {
        onDemandCycle++;
        int i = 20;
        if (highestPriority == 0 && clientInstance.caches[0] != null) i = 50;
        try {
          Thread.sleep(i);
        } catch (Exception _ex) {
        }
        waiting = true;
        for (int j = 0; j < 100; j++) {
          if (!waiting) break;
          waiting = false;
          checkReceived();
          handleFailed();
          if (uncompletedCount == 0 && j >= 5) break;
          method568();
          if (inputStream != null) readData();
        }

        boolean flag = false;
        for (OnDemandData onDemandData = (OnDemandData) requested.peekLast();
            onDemandData != null;
            onDemandData = (OnDemandData) requested.reverseGetNext())
          if (onDemandData.incomplete) {
            flag = true;
            onDemandData.loopCycle++;
            if (onDemandData.loopCycle > 50) {
              onDemandData.loopCycle = 0;
              closeRequest(onDemandData);
            }
          }

        if (!flag) {
          for (OnDemandData onDemandData_1 = (OnDemandData) requested.peekLast();
              onDemandData_1 != null;
              onDemandData_1 = (OnDemandData) requested.reverseGetNext()) {
            flag = true;
            onDemandData_1.loopCycle++;
            if (onDemandData_1.loopCycle > 50) {
              onDemandData_1.loopCycle = 0;
              closeRequest(onDemandData_1);
            }
          }
        }
        if (flag) {
          loopCycle++;
          if (loopCycle > 750) {
            try {
              socket.close();
            } catch (Exception _ex) {
            }
            socket = null;
            inputStream = null;
            outputStream = null;
            expectedSize = 0;
          }
        } else {
          loopCycle = 0;
          statusString = "";
        }
        if (clientInstance.loggedIn
            && socket != null
            && outputStream != null
            && (highestPriority > 0 || clientInstance.caches[0] == null)) {
          writeLoopCycle++;
          if (writeLoopCycle > 500) {
            writeLoopCycle = 0;
            ioBuffer[0] = 0;
            ioBuffer[1] = 0;
            ioBuffer[2] = 0;
            ioBuffer[3] = 10;
            try {
              outputStream.write(ioBuffer, 0, 4);
            } catch (IOException _ex) {
              loopCycle = 5000;
            }
          }
        }
      }
    } catch (Exception exception) {
      signlink.reporterror("od_ex " + exception.getMessage());
    }
  }