Changeset 399a05a


Ignore:
Timestamp:
Jun 14, 2011 7:37:30 PM (9 years ago)
Author:
zzz <zzz@…>
Branches:
master
Children:
89191f4
Parents:
932f01df
Message:
  • Router: Delete old libjbigi.so and libjcpuid.so at startup if jbigi.jar is newer.

This will force a reextraction by CPUID and NBI.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • router/java/src/net/i2p/router/Router.java

    r932f01df r399a05a  
    11241124    }
    11251125   
     1126    /**
     1127     *  A "soft" restart, primarily of the comm system, after
     1128     *  a port change or large step-change in system time.
     1129     *  Does not stop the whole JVM, so it is safe even in the absence
     1130     *  of the wrapper.
     1131     *  This is not a graceful restart - all peer connections are dropped.
     1132     */
    11261133    public void restart() {
    11271134        _isAlive = false;
    11281135       
    11291136        try { _context.commSystem().restart(); } catch (Throwable t) { _log.log(Log.CRIT, "Error restarting the comm system", t); }
    1130         //try { _context.adminManager().restart(); } catch (Throwable t) { _log.log(Log.CRIT, "Error restarting the client manager", t); }
    11311137        try { _context.clientManager().restart(); } catch (Throwable t) { _log.log(Log.CRIT, "Error restarting the client manager", t); }
    11321138        try { _context.tunnelManager().restart(); } catch (Throwable t) { _log.log(Log.CRIT, "Error restarting the tunnel manager", t); }
     
    12331239            }
    12341240            System.exit(EXIT_HARD_RESTART);
     1241        } else {
     1242            // Remove extracted libjbigi.so and libjcpuid.so files if we have a newer jbigi.jar,
     1243            // so the new ones will be extracted.
     1244            // We do this after the restart, not after the extract, because it's safer, and
     1245            // because people may upgrade their jbigi.jar file manually.
     1246
     1247            // Copied from NativeBigInteger, which we can't access here or the
     1248            // libs will get loaded.
     1249            String osArch = System.getProperty("os.arch");
     1250            boolean isX86 = osArch.contains("86") || osArch.equals("amd64");
     1251            String osName = System.getProperty("os.name").toLowerCase();
     1252            boolean isWin = osName.startsWith("win");
     1253            boolean isMac = osName.startsWith("mac");
     1254            // only do this on these OSes
     1255            boolean goodOS = isWin || isMac ||
     1256                             osName.contains("linux") || osName.contains("freebsd");
     1257
     1258            // only do this on these x86
     1259            File jbigiJar = new File(_context.getBaseDir(), "lib/jbigi.jar");
     1260            if (isX86 && goodOS && jbigiJar.exists()) {
     1261                String libPrefix = (isWin ? "" : "lib");
     1262                String libSuffix = (isWin ? ".dll" : isMac ? ".jnilib" : ".so");
     1263
     1264                File jcpuidLib = new File(_context.getBaseDir(), libPrefix + "jcpuid" + libSuffix);
     1265                if (jcpuidLib.canWrite() && jbigiJar.lastModified() > jcpuidLib.lastModified()) {
     1266                    String path = jcpuidLib.getAbsolutePath();
     1267                    boolean success = FileUtil.copy(path, path + ".bak", true, true);
     1268                    if (success) {
     1269                        boolean success2 = jcpuidLib.delete();
     1270                        if (success2)
     1271                            System.out.println("New jbigi.jar detected, moved jcpuid library to " +
     1272                                               path + ".bak, check logs for successful installation of new library");
     1273                    }
     1274                }
     1275
     1276                File jbigiLib = new File(_context.getBaseDir(), libPrefix + "jbigi" + libSuffix);
     1277                if (jbigiLib.canWrite() && jbigiJar.lastModified() > jbigiLib.lastModified()) {
     1278                    String path = jbigiLib.getAbsolutePath();
     1279                    boolean success = FileUtil.copy(path, path + ".bak", true, true);
     1280                    if (success) {
     1281                        boolean success2 = jbigiLib.delete();
     1282                        if (success2)
     1283                            System.out.println("New jbigi.jar detected, moved jbigi library to " +
     1284                                               path + ".bak, check logs for successful installation of new library");
     1285                    }
     1286                }
     1287            }
    12351288        }
    12361289    }
Note: See TracChangeset for help on using the changeset viewer.