private void processOpenFrame(int channelPtr,
                                  int ctype,
                                  int flag,
                                  ByteBuffer data) {
        OpenRequest request;
        Channel channel;

        synchronized (this) {
            request = m_pendingOpenRequest;
        }

        if (request == null) {
            destroy(new ChannelError("The server sent a invalid open frame"));
            return;
        }

        channel = request.getChannel();

        synchronized (this) {
            m_pendingOpenRequest = null;
        }

        if (flag == Frame.OPEN_ALLOW) {
            m_openChannels.put(channelPtr, channel);

            if (HydnaDebug.HYDNADEBUG) {
                DebugHelper.debugPrint("Connection", channelPtr, "A new channel was added");
                DebugHelper.debugPrint("Connection", channelPtr, "The size of openChannels is now " + m_openChannels.size());
            }

            channel.openSuccess(channelPtr, ctype, data);

            return;
        }

        if (HydnaDebug.HYDNADEBUG) {
            DebugHelper.debugPrint("Connection", channelPtr, "The server rejected the open request, errorcode " + flag);
        }

        ChannelError error = ChannelError.fromOpenError(flag, ctype, data);
        channel.destroy(error);
    }