View | Details | Raw Unified | Return to bug 56713
Collapse All | Expand All

(-)java/org/apache/catalina/connector/CoyoteAdapter.java (-4 / +41 lines)
Lines 856-861 Link Here
856
        Context versionContext = null;
856
        Context versionContext = null;
857
        boolean mapRequired = true;
857
        boolean mapRequired = true;
858
858
859
        Context reloadingContext = null;
860
        long reloadingWaitStartTime = 0;
861
859
        while (mapRequired) {
862
        while (mapRequired) {
860
            // This will map the the latest version by default
863
            // This will map the the latest version by default
861
            connector.getService().getMapper().map(serverName, decodedURI,
864
            connector.getService().getMapper().map(serverName, decodedURI,
Lines 934-944 Link Here
934
                // Found a matching context but it is paused. Mapping data will
937
                // Found a matching context but it is paused. Mapping data will
935
                // be wrong since some Wrappers may not be registered at this
938
                // be wrong since some Wrappers may not be registered at this
936
                // point.
939
                // point.
937
                try {
940
938
                    Thread.sleep(1000);
941
                boolean wait = true;
939
                } catch (InterruptedException e) {
942
                if (reloadingContext == null
940
                    // Should never happen
943
                        || request.getContext() != reloadingContext) {
944
                    reloadingContext = request.getContext();
945
                    reloadingWaitStartTime = System.currentTimeMillis();
946
                } else {
947
                    final long maxReloadingWaitTime = 120000;
948
                    long reloadingWaitTime = System.currentTimeMillis()
949
                            - reloadingWaitStartTime;
950
                    if (reloadingWaitTime > maxReloadingWaitTime) {
951
                        String contextPath = reloadingContext.getPath();
952
                        if ("/".equals(contextPath)) {
953
                            contextPath = "";
954
                        }
955
                        connector.getService().getMapper()
956
                                .removePausedContext(reloadingContext,
957
                                        request.getHost().getName(),
958
                                        contextPath,
959
                                        reloadingContext.getWebappVersion());
960
                        reloadingContext = null;
961
                        versionContext = null;
962
                        wait = false;
963
                    }
941
                }
964
                }
965
                if (wait) {
966
                    try {
967
                        Thread.sleep(1000);
968
                    } catch (InterruptedException e) {
969
                        // Should never happen
970
                    }
971
                    if (!connector.getState().isAvailable()) {
972
                        res.setStatus(503);
973
                        connector.getService().getContainer().logAccess(
974
                                request, response, 0, true);
975
                        return false;
976
                    }
977
                }
978
942
                // Reset mapping
979
                // Reset mapping
943
                request.getMappingData().recycle();
980
                request.getMappingData().recycle();
944
                mapRequired = true;
981
                mapRequired = true;
(-)java/org/apache/catalina/mapper/Mapper.java (+23 lines)
Lines 355-361 Link Here
355
        }
355
        }
356
    }
356
    }
357
357
358
    /**
359
     * Remove mapping for a context that is being restarted for a too long time.
360
     */
361
    public void removePausedContext(Context ctxt, String hostName,
362
            String contextPath, String version) {
363
        MappedHost mappedHost = exactFind(hosts, hostName);
364
        ContextVersion contextVersion = findContextVersion(hostName,
365
                contextPath, version, true);
366
        if (mappedHost == null || contextVersion == null
367
                || !contextVersion.isPaused()) {
368
            return;
369
        }
370
        synchronized (mappedHost) {
371
            // Repeating the check, because of race with addContextVersion()
372
            contextVersion = findContextVersion(hostName, contextPath, version,
373
                    true);
374
            if (contextVersion == null || !contextVersion.isPaused()) {
375
                return;
376
            }
377
            removeContextVersion(ctxt, hostName, contextPath, version);
378
        }
379
    }
358
380
381
359
    /**
382
    /**
360
     * Mark a context as being reloaded. Reversion of this state is performed
383
     * Mark a context as being reloaded. Reversion of this state is performed
361
     * by calling <code>addContextVersion(...)</code> when context starts up.
384
     * by calling <code>addContextVersion(...)</code> when context starts up.

Return to bug 56713