svn commit: r1603786 - in /qpid/trunk/qpid/java/broker-core/src: main/java/org/apache/qpid/server/plugin/ main/java/org/apache/qpid/server/protocol/ test/java/org/apache/qpid/server/plugin/
Author: macbean Date: Thu Jun 19 09:38:35 2014 New Revision: 1603786 URL: http://svn.apache.org/r1603786 Log: QPID-5825: Broker tries to downgrade to the wrong amqp protocol version Added: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparator.java qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/plugin/ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapperTest.java qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparatorTest.java Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/protocol/MultiVersionProtocolEngineFactory.java Added: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java?rev=1603786&view=auto == --- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java (added) +++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java Thu Jun 19 09:38:35 2014 @@ -0,0 +1,131 @@ +package org.apache.qpid.server.plugin; + +import org.apache.commons.lang.StringUtils; +import org.apache.qpid.server.model.Protocol; + +public class AMQPProtocolVersionWrapper +{ +private static final char DELIMITER = '_'; + +private int major; +private int minor; +private int patch; + +public AMQPProtocolVersionWrapper(Protocol amqpProtocol) +{ +if (!amqpProtocol.isAMQP()) +{ +throw new IllegalArgumentException("Protocol must be of type " + Protocol.ProtocolType.AMQP); +} + +final String[] parts = StringUtils.split(amqpProtocol.name(), DELIMITER); +for (int i = 0; i < parts.length; i++) +{ +switch (i) +{ +case 1: this.major = Integer.parseInt(parts[i]); +break; +case 2: this.minor = Integer.parseInt(parts[i]); +break; +case 3: this.patch = Integer.parseInt(parts[i]); +break; +} +} +} + +public AMQPProtocolVersionWrapper(int major, int minor, int patch) +{ +this.major = major; +this.minor = minor; +this.patch = patch; +} + +public int getMajor() +{ +return major; +} + +public void setMajor(int major) +{ +this.major = major; +} + +public int getMinor() +{ +return minor; +} + +public void setMinor(int minor) +{ +this.minor = minor; +} + +public int getPatch() +{ +return patch; +} + +public void setPatch(int patch) +{ +this.patch = patch; +} + +public Protocol getProtocol() +{ +return Protocol.valueOf(this.toString()); +} + +@Override +public boolean equals(Object o) +{ +if (this == o) +{ +return true; +} +if (!(o instanceof AMQPProtocolVersionWrapper)) +{ +return false; +} + +final AMQPProtocolVersionWrapper number = (AMQPProtocolVersionWrapper) o; + +if (this.major != number.major) +{ +return false; +} +else if (this.minor != number.minor) +{ +return false; +} +else if (this.patch != number.patch) +{ +return false; +} +else +{ +return true; +} +} + +@Override +public int hashCode() +{ +int result = major; +result = 31 * result + minor; +result = 31 * result + patch; +return result; +} + +@Override +public String toString() +{ +final StringBuilder sb = new StringBuilder(Protocol.ProtocolType.AMQP.name()).append(DELIMITER) + .append(major).append(DELIMITER) + .append(minor); +if (patch != 0) +{ +sb.append(DELIMITER).append(patch); +} +return sb.toString(); +} +} Added: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparator.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparator.java?rev=1603786&view=auto == --- qpid/trunk/qpid/java/broker-core/src/main/java/or
svn commit: r1603791 - /qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java
Author: macbean Date: Thu Jun 19 09:42:45 2014 New Revision: 1603791 URL: http://svn.apache.org/r1603791 Log: QPID-5831: Unexpected internal exception when closing JE Replicated environment Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java?rev=1603791&r1=1603790&r2=1603791&view=diff == --- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java (original) +++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/replication/ReplicatedEnvironmentFacade.java Thu Jun 19 09:42:45 2014 @@ -782,8 +782,28 @@ public class ReplicatedEnvironmentFacade } finally { -_environment.close(); -_environment = null; +// Try closing the environment but swallow EnvironmentFailureException +// if the environment becomes invalid while closing. +// This can be caused by potential race between facade close and DatabasePinger open. +try +{ +_environment.close(); +} +catch (EnvironmentFailureException efe) +{ +if (!_environment.isValid()) +{ +LOGGER.debug("Environment became invalid on close, so ignore", efe); +} +else +{ +throw efe; +} +} +finally +{ +_environment = null; +} } } - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
svn commit: r1603849 [1/2] - in /qpid/trunk/qpid/java/bdbstore/src: main/java/org/apache/qpid/server/store/berkeleydb/ main/java/org/apache/qpid/server/virtualhost/berkeleydb/ test/java/org/apache/qpi
Author: kwall Date: Thu Jun 19 12:07:14 2014 New Revision: 1603849 URL: http://svn.apache.org/r1603849 Log: QPID-5800: [Java Broker] Refactor BDB message store implementation to separate message and config store implementations. * Message store implementations can now be used in isolation, which is useful when the user is using a JSON VirtualHostNode with a BDB virtual host. Added: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStore.java qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBUtils.java Modified: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/BDBConfigurationStore.java qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/virtualhost/berkeleydb/BDBVirtualHost.java qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreQuotaEventsTest.java qpid/trunk/qpid/java/bdbstore/src/test/java/org/apache/qpid/server/store/berkeleydb/BDBMessageStoreTest.java Added: qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java?rev=1603849&view=auto == --- qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java (added) +++ qpid/trunk/qpid/java/bdbstore/src/main/java/org/apache/qpid/server/store/berkeleydb/AbstractBDBMessageStore.java Thu Jun 19 12:07:14 2014 @@ -0,0 +1,1219 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +package org.apache.qpid.server.store.berkeleydb; + +import static org.apache.qpid.server.store.berkeleydb.BDBUtils.*; +import static org.apache.qpid.server.store.berkeleydb.BDBUtils.abortTransactionSafely; +import static org.apache.qpid.server.store.berkeleydb.BDBUtils.closeCursorSafely; +import static org.apache.qpid.server.store.berkeleydb.BDBUtils.DEFAULT_DATABASE_CONFIG; + +import java.lang.ref.SoftReference; +import java.nio.ByteBuffer; +import java.nio.charset.Charset; +import java.util.ArrayList; +import java.util.List; +import java.util.Random; +import java.util.UUID; + +import com.sleepycat.bind.tuple.ByteBinding; +import com.sleepycat.bind.tuple.LongBinding; +import com.sleepycat.je.CheckpointConfig; +import com.sleepycat.je.Cursor; +import com.sleepycat.je.Database; +import com.sleepycat.je.DatabaseEntry; +import com.sleepycat.je.DatabaseException; +import com.sleepycat.je.EnvironmentConfig; +import com.sleepycat.je.LockConflictException; +import com.sleepycat.je.LockMode; +import com.sleepycat.je.OperationStatus; +import com.sleepycat.je.Sequence; +import com.sleepycat.je.SequenceConfig; +import com.sleepycat.je.Transaction; +import org.apache.log4j.Logger; + +import org.apache.qpid.server.message.EnqueueableMessage; +import org.apache.qpid.server.model.ConfiguredObject; +import org.apache.qpid.server.store.Event; +import org.apache.qpid.server.store.EventListener; +import org.apache.qpid.server.store.EventManager; +import org.apache.qpid.server.store.MessageStore; +import org.apache.qpid.server.store.StorableMessageMetaData; +import org.apache.qpid.server.store.StoreException; +import org.apache.qpid.server.store.StoreFuture; +import org.apache.qpid.server.store.StoredMemoryMessage; +import org.apache.qpid.server.store.StoredMessage; +import org.apache.qpid.server.store.TransactionLogResource; +import org.apache.qpid.server.store.Xid; +import org.apache.qpid.server.store.berkeleydb.entry.PreparedTransaction; +import org.apache.qpid.server.store.berkeleydb.entry.QueueEntryKey; +import org.apache.qpid.server.store.berkeleydb.tuple.ContentBinding; +import org.apache.qpid.server.store.berkeleydb.tuple.MessageMetaDataBinding; +import org.apache.qpid.server.store.berkeleydb.tuple.PreparedTransactionBinding; +import org.apache.qpid.server.store.berkeleydb.tu
svn commit: r1603914 - in /qpid/trunk/qpid/java: broker-core/src/main/java/org/apache/qpid/server/plugin/ broker-core/src/test/java/org/apache/qpid/server/plugin/ systests/src/main/java/org/apache/qpi
Author: macbean Date: Thu Jun 19 15:08:16 2014 New Revision: 1603914 URL: http://svn.apache.org/r1603914 Log: QPID-5825: Changes to address some review comments for initial commit Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparator.java qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapperTest.java qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/plugin/ProtocolEngineCreatorComparatorTest.java qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/server/SupportedProtocolVersionsTest.java qpid/trunk/qpid/java/systests/src/main/java/org/apache/qpid/test/utils/QpidBrokerTestCase.java Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java?rev=1603914&r1=1603913&r2=1603914&view=diff == --- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java (original) +++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/plugin/AMQPProtocolVersionWrapper.java Thu Jun 19 15:08:16 2014 @@ -1,3 +1,23 @@ +/* + * + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + * + */ package org.apache.qpid.server.plugin; import org.apache.commons.lang.StringUtils; @@ -5,11 +25,11 @@ import org.apache.qpid.server.model.Prot public class AMQPProtocolVersionWrapper { -private static final char DELIMITER = '_'; +static final char DELIMITER = '_'; -private int major; -private int minor; -private int patch; +private int _major; +private int _minor; +private int _patch; public AMQPProtocolVersionWrapper(Protocol amqpProtocol) { @@ -23,51 +43,29 @@ public class AMQPProtocolVersionWrapper { switch (i) { -case 1: this.major = Integer.parseInt(parts[i]); +case 1: this._major = Integer.parseInt(parts[i]); break; -case 2: this.minor = Integer.parseInt(parts[i]); +case 2: this._minor = Integer.parseInt(parts[i]); break; -case 3: this.patch = Integer.parseInt(parts[i]); +case 3: this._patch = Integer.parseInt(parts[i]); break; } } } -public AMQPProtocolVersionWrapper(int major, int minor, int patch) -{ -this.major = major; -this.minor = minor; -this.patch = patch; -} - public int getMajor() { -return major; -} - -public void setMajor(int major) -{ -this.major = major; +return _major; } public int getMinor() { -return minor; -} - -public void setMinor(int minor) -{ -this.minor = minor; +return _minor; } public int getPatch() { -return patch; -} - -public void setPatch(int patch) -{ -this.patch = patch; +return _patch; } public Protocol getProtocol() @@ -89,15 +87,15 @@ public class AMQPProtocolVersionWrapper final AMQPProtocolVersionWrapper number = (AMQPProtocolVersionWrapper) o; -if (this.major != number.major) +if (this._major != number._major) { return false; } -else if (this.minor != number.minor) +else if (this._minor != number._minor) { return false; } -else if (this.patch != number.patch) +else if (this._patch != number._patch) { return false; } @@ -110,9 +108,9 @@ public class AMQPProtocolVersionWrapper @Override public int hashCode() { -int result = major; -result = 31 * result + minor; -result = 31 *
svn commit: r1603949 - in /qpid/proton/trunk/proton-c/src: engine/engine.c engine/event.c engine/event.h transport/transport.c
Author: rhs Date: Thu Jun 19 17:21:52 2014 New Revision: 1603949 URL: http://svn.apache.org/r1603949 Log: removed type specific initializers Modified: qpid/proton/trunk/proton-c/src/engine/engine.c qpid/proton/trunk/proton-c/src/engine/event.c qpid/proton/trunk/proton-c/src/engine/event.h qpid/proton/trunk/proton-c/src/transport/transport.c Modified: qpid/proton/trunk/proton-c/src/engine/engine.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1603949&r1=1603948&r2=1603949&view=diff == --- qpid/proton/trunk/proton-c/src/engine/engine.c (original) +++ qpid/proton/trunk/proton-c/src/engine/engine.c Thu Jun 19 17:21:52 2014 @@ -66,18 +66,18 @@ static void endpoint_init_event(pn_event switch (endpoint->type) { case CONNECTION: { pn_connection_t *conn = (pn_connection_t *) endpoint; - pn_event_init_connection(event, conn); + pn_event_init(event, conn); } break; case SESSION: { pn_session_t *ssn = (pn_session_t *) endpoint; - pn_event_init_session(event, ssn); + pn_event_init(event, ssn); } break; case SENDER: case RECEIVER: { pn_link_t *link = (pn_link_t*) endpoint; - pn_event_init_link(event, link); + pn_event_init(event, link); } break; } @@ -596,7 +596,7 @@ void pn_modified(pn_connection_t *connec if (emit) { pn_event_t *event = pn_collector_put(connection->collector, PN_TRANSPORT); if (event) { - pn_event_init_transport(event, connection->transport); + pn_event_init(event, connection->transport); } } } Modified: qpid/proton/trunk/proton-c/src/engine/event.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/event.c?rev=1603949&r1=1603948&r2=1603949&view=diff == --- qpid/proton/trunk/proton-c/src/engine/event.c (original) +++ qpid/proton/trunk/proton-c/src/engine/event.c Thu Jun 19 17:21:52 2014 @@ -176,36 +176,11 @@ pn_event_t *pn_event(void) return event; } -void pn_event_init_context(pn_event_t *event, void *object) +void pn_event_init(pn_event_t *event, void *context) { -event->context = object; -if (event->context) -pn_incref(event->context); -} - -void pn_event_init_transport(pn_event_t *event, pn_transport_t *transport) -{ - pn_event_init_context(event, transport); -} - -void pn_event_init_connection(pn_event_t *event, pn_connection_t *connection) -{ - pn_event_init_context(event, connection); -} - -void pn_event_init_session(pn_event_t *event, pn_session_t *session) -{ - pn_event_init_context(event, session); -} - -void pn_event_init_link(pn_event_t *event, pn_link_t *link) -{ - pn_event_init_context(event, link); -} - -void pn_event_init_delivery(pn_event_t *event, pn_delivery_t *delivery) -{ - pn_event_init_context(event, delivery); + event->context = context; + if (event->context) +pn_incref(event->context); } pn_event_type_t pn_event_type(pn_event_t *event) Modified: qpid/proton/trunk/proton-c/src/engine/event.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/event.h?rev=1603949&r1=1603948&r2=1603949&view=diff == --- qpid/proton/trunk/proton-c/src/engine/event.h (original) +++ qpid/proton/trunk/proton-c/src/engine/event.h Thu Jun 19 17:21:52 2014 @@ -24,10 +24,6 @@ pn_event_t *pn_collector_put(pn_collector_t *collector, pn_event_type_t type); -void pn_event_init_transport(pn_event_t *event, pn_transport_t *transport); -void pn_event_init_connection(pn_event_t *event, pn_connection_t *connection); -void pn_event_init_session(pn_event_t *event, pn_session_t *session); -void pn_event_init_link(pn_event_t *event, pn_link_t *link); -void pn_event_init_delivery(pn_event_t *event, pn_delivery_t *delivery); +void pn_event_init(pn_event_t *event, void *context); #endif /* event.h */ Modified: qpid/proton/trunk/proton-c/src/transport/transport.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/transport/transport.c?rev=1603949&r1=1603948&r2=1603949&view=diff == --- qpid/proton/trunk/proton-c/src/transport/transport.c (original) +++ qpid/proton/trunk/proton-c/src/transport/transport.c Thu Jun 19 17:21:52 2014 @@ -268,7 +268,7 @@ int pn_transport_bind(pn_transport_t *tr pn_event_t *event = pn_collector_put(connection->collector, PN_CONNECTION_REMOTE_STATE); if (event) { - pn_event_init_connection(event, connection); + pn_event_init(event, connection); } if (!pn_error_code(transport->error)) { transport->disp->halt = false; @@ -458,7 +458,7 @@ int pn_do_open(pn_dispatcher_t *disp) pn_event_t *event = pn_collector_put(conn->collector
svn commit: r1603946 - in /qpid/proton/trunk/proton-c/src/engine: engine.c event.c
Author: rhs Date: Thu Jun 19 17:21:18 2014 New Revision: 1603946 URL: http://svn.apache.org/r1603946 Log: change events to use a single context Modified: qpid/proton/trunk/proton-c/src/engine/engine.c qpid/proton/trunk/proton-c/src/engine/event.c Modified: qpid/proton/trunk/proton-c/src/engine/engine.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1603946&r1=1603945&r2=1603946&view=diff == --- qpid/proton/trunk/proton-c/src/engine/engine.c (original) +++ qpid/proton/trunk/proton-c/src/engine/engine.c Thu Jun 19 17:21:18 2014 @@ -596,7 +596,7 @@ void pn_modified(pn_connection_t *connec if (emit) { pn_event_t *event = pn_collector_put(connection->collector, PN_TRANSPORT); if (event) { - pn_event_init_connection(event, connection); + pn_event_init_transport(event, connection->transport); } } } Modified: qpid/proton/trunk/proton-c/src/engine/event.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/event.c?rev=1603946&r1=1603945&r2=1603946&view=diff == --- qpid/proton/trunk/proton-c/src/engine/event.c (original) +++ qpid/proton/trunk/proton-c/src/engine/event.c Thu Jun 19 17:21:18 2014 @@ -9,11 +9,7 @@ struct pn_collector_t { }; struct pn_event_t { - pn_connection_t *connection; - pn_session_t *session; - pn_link_t *link; - pn_delivery_t *delivery; - pn_transport_t *transport; + void *context;// depends on type pn_event_t *next; pn_event_type_t type; }; @@ -84,6 +80,7 @@ void pn_collector_free(pn_collector_t *c pn_event_t *pn_event(void); static void pn_event_initialize(void *obj); +static bool pn_event_is_valid(pn_event_t *event); pn_event_t *pn_collector_put(pn_collector_t *collector, pn_event_type_t type) { @@ -120,15 +117,7 @@ pn_event_t *pn_collector_peek(pn_collect { // discard any events for objects that no longer exist pn_event_t *event = collector->head; - while (event && ((event->delivery && event->delivery->local.settled) - || - (event->link && event->link->endpoint.freed) - || - (event->session && event->session->endpoint.freed) - || - (event->connection && event->connection->endpoint.freed) - || - (event->transport && event->transport->freed))) { + while (event && !pn_event_is_valid(event)) { pn_collector_pop(collector); event = collector->head; } @@ -151,11 +140,10 @@ bool pn_collector_pop(pn_collector_t *co event->next = collector->free_head; collector->free_head = event; - if (event->connection) pn_decref(event->connection); - if (event->session) pn_decref(event->session); - if (event->link) pn_decref(event->link); - if (event->delivery) pn_decref(event->delivery); - if (event->transport) pn_decref(event->transport); + if (event->context) { +pn_decref(event->context); +event->context = NULL; + } return true; } @@ -164,11 +152,7 @@ static void pn_event_initialize(void *ob { pn_event_t *event = (pn_event_t *) obj; event->type = PN_EVENT_NONE; - event->connection = NULL; - event->session = NULL; - event->link = NULL; - event->delivery = NULL; - event->transport = NULL; + event->context = NULL; event->next = NULL; } @@ -178,16 +162,12 @@ static int pn_event_inspect(void *obj, p { assert(obj); pn_event_t *event = (pn_event_t *) obj; - int err = pn_string_addf(dst, "(%d", event->type); - void *objects[] = {event->connection, event->session, event->link, - event->delivery, event->transport}; - for (int i = 0; i < 5; i++) { -if (objects[i]) { - err = pn_string_addf(dst, ", "); - if (err) return err; - err = pn_inspect(objects[i], dst); - if (err) return err; -} + int err = pn_string_addf(dst, "(0x%X", (unsigned int)event->type); + if (event->context) { +err = pn_string_addf(dst, ", "); +if (err) return err; +err = pn_inspect(event->context, dst); +if (err) return err; } return pn_string_addf(dst, ")"); @@ -203,38 +183,36 @@ pn_event_t *pn_event(void) return event; } +void pn_event_init_context(pn_event_t *event, void *object) +{ +event->context = object; +if (event->context) +pn_incref(event->context); +} + void pn_event_init_transport(pn_event_t *event, pn_transport_t *transport) { - event->transport = transport; - pn_incref(event->transport); + pn_event_init_context(event, transport); } void pn_event_init_connection(pn_event_t *event, pn_connection_t *connection) { - event->connection = connection; - pn_event_init_transport(event, event->connection->transport); - pn_incref(event->connection); + pn_event_init_context(event, connection); } void pn_event_init_session(pn_event_t *event, pn_
svn commit: r1603948 - /qpid/proton/trunk/proton-c/src/engine/event.c
Author: rhs Date: Thu Jun 19 17:21:44 2014 New Revision: 1603948 URL: http://svn.apache.org/r1603948 Log: removed extraneous is_valid check Modified: qpid/proton/trunk/proton-c/src/engine/event.c Modified: qpid/proton/trunk/proton-c/src/engine/event.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/event.c?rev=1603948&r1=1603947&r2=1603948&view=diff == --- qpid/proton/trunk/proton-c/src/engine/event.c (original) +++ qpid/proton/trunk/proton-c/src/engine/event.c Thu Jun 19 17:21:44 2014 @@ -80,7 +80,6 @@ void pn_collector_free(pn_collector_t *c pn_event_t *pn_event(void); static void pn_event_initialize(void *obj); -static bool pn_event_is_valid(pn_event_t *event); pn_event_t *pn_collector_put(pn_collector_t *collector, pn_event_type_t type) { @@ -115,12 +114,6 @@ pn_event_t *pn_collector_put(pn_collecto pn_event_t *pn_collector_peek(pn_collector_t *collector) { - // discard any events for objects that no longer exist - pn_event_t *event = collector->head; - while (event && !pn_event_is_valid(event)) { -pn_collector_pop(collector); -event = collector->head; - } return collector->head; } @@ -322,18 +315,3 @@ const char *pn_event_type_name(pn_event_ return ""; } - -static bool pn_event_is_valid(pn_event_t *event) -{ - pn_delivery_t *d; - pn_link_t *l; - pn_session_t *s; - pn_connection_t *c; - pn_transport_t *t; - return (event && - (!(d = pn_event_delivery(event)) || !d->local.settled) && - (!(l = pn_event_link(event)) || !l->endpoint.freed) && - (!(s = pn_event_session(event)) || !s->endpoint.freed) && - (!(c = pn_event_connection(event)) || !c->endpoint.freed) && - (!(t = pn_event_transport(event)) || !t->freed)); -} - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
svn commit: r1603950 - /qpid/proton/trunk/proton-c/src/object/object.c
Author: rhs Date: Thu Jun 19 17:22:01 2014 New Revision: 1603950 URL: http://svn.apache.org/r1603950 Log: check that finalize did not create a new ref Modified: qpid/proton/trunk/proton-c/src/object/object.c Modified: qpid/proton/trunk/proton-c/src/object/object.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/object/object.c?rev=1603950&r1=1603949&r2=1603950&view=diff == --- qpid/proton/trunk/proton-c/src/object/object.c (original) +++ qpid/proton/trunk/proton-c/src/object/object.c Thu Jun 19 17:22:01 2014 @@ -70,7 +70,11 @@ void pn_decref(void *object) head->refcount--; if (!head->refcount) { pn_finalize(object); - free(head); + // Check the refcount again in case finalize created a new + // reference. + if (!head->refcount) { +free(head); + } } } } - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
svn commit: r1603951 - /qpid/proton/trunk/proton-c/src/object/object.c
Author: rhs Date: Thu Jun 19 17:22:10 2014 New Revision: 1603951 URL: http://svn.apache.org/r1603951 Log: don't zero out refcount in pn_finalize Modified: qpid/proton/trunk/proton-c/src/object/object.c Modified: qpid/proton/trunk/proton-c/src/object/object.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/object/object.c?rev=1603951&r1=1603950&r2=1603951&view=diff == --- qpid/proton/trunk/proton-c/src/object/object.c (original) +++ qpid/proton/trunk/proton-c/src/object/object.c Thu Jun 19 17:22:10 2014 @@ -87,7 +87,6 @@ void pn_finalize(void *object) if (head->clazz && head->clazz->finalize) { head->clazz->finalize(object); } -head->refcount = 0; } } - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
svn commit: r1603955 - in /qpid/proton/trunk/proton-c: include/proton/event.h src/engine/engine.c src/engine/event.c src/engine/event.h src/transport/transport.c
Author: rhs Date: Thu Jun 19 17:22:43 2014 New Revision: 1603955 URL: http://svn.apache.org/r1603955 Log: made pn_collector_put take the context as an argument Modified: qpid/proton/trunk/proton-c/include/proton/event.h qpid/proton/trunk/proton-c/src/engine/engine.c qpid/proton/trunk/proton-c/src/engine/event.c qpid/proton/trunk/proton-c/src/engine/event.h qpid/proton/trunk/proton-c/src/transport/transport.c Modified: qpid/proton/trunk/proton-c/include/proton/event.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/event.h?rev=1603955&r1=1603954&r2=1603955&view=diff == --- qpid/proton/trunk/proton-c/include/proton/event.h (original) +++ qpid/proton/trunk/proton-c/include/proton/event.h Thu Jun 19 17:22:43 2014 @@ -220,6 +220,11 @@ PN_EXTERN pn_event_type_t pn_event_type( PN_EXTERN pn_event_category_t pn_event_category(pn_event_t *event); /** + * Get the context associated with an event. + */ +PN_EXTERN void *pn_event_context(pn_event_t *event); + +/** * Get the connection associated with an event. * * @param[in] event an event object Modified: qpid/proton/trunk/proton-c/src/engine/engine.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1603955&r1=1603954&r2=1603955&view=diff == --- qpid/proton/trunk/proton-c/src/engine/engine.c (original) +++ qpid/proton/trunk/proton-c/src/engine/engine.c Thu Jun 19 17:22:43 2014 @@ -64,11 +64,8 @@ static void pn_endpoint_open(pn_endpoint // TODO: do we care about the current state? PN_SET_LOCAL(endpoint->state, PN_LOCAL_ACTIVE); pn_connection_t *conn = pn_ep_get_connection(endpoint); - pn_event_t *event = pn_collector_put(conn->collector, - endpoint_event_map[endpoint->type]); - if (event) { -pn_event_init(event, endpoint); - } + pn_collector_put(conn->collector, endpoint_event_map[endpoint->type], + endpoint); pn_modified(conn, endpoint, true); } @@ -77,11 +74,8 @@ static void pn_endpoint_close(pn_endpoin // TODO: do we care about the current state? PN_SET_LOCAL(endpoint->state, PN_LOCAL_CLOSED); pn_connection_t *conn = pn_ep_get_connection(endpoint); - pn_event_t *event = pn_collector_put(conn->collector, - endpoint_event_map[endpoint->type]); - if (event) { -pn_event_init(event, endpoint); - } + pn_collector_put(conn->collector, endpoint_event_map[endpoint->type], + endpoint); pn_modified(conn, endpoint, true); } @@ -343,11 +337,8 @@ static bool pni_post_final(pn_endpoint_t pn_connection_t *conn = pn_ep_get_connection(endpoint); if (!endpoint->posted_final) { endpoint->posted_final = true; -pn_event_t *event = pn_collector_put(conn->collector, type); -if (event) { - pn_event_init(event, endpoint); - return true; -} +pn_event_t *event = pn_collector_put(conn->collector, type, endpoint); +if (event) { return true; } } return false; @@ -592,10 +583,8 @@ void pn_modified(pn_connection_t *connec } if (emit && connection->transport) { -pn_event_t *event = pn_collector_put(connection->collector, PN_TRANSPORT); -if (event) { - pn_event_init(event, connection->transport); -} +pn_collector_put(connection->collector, PN_TRANSPORT, + connection->transport); } } Modified: qpid/proton/trunk/proton-c/src/engine/event.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/event.c?rev=1603955&r1=1603954&r2=1603955&view=diff == --- qpid/proton/trunk/proton-c/src/engine/event.c (original) +++ qpid/proton/trunk/proton-c/src/engine/event.c Thu Jun 19 17:22:43 2014 @@ -81,12 +81,14 @@ void pn_collector_free(pn_collector_t *c pn_event_t *pn_event(void); static void pn_event_initialize(void *obj); -pn_event_t *pn_collector_put(pn_collector_t *collector, pn_event_type_t type) +pn_event_t *pn_collector_put(pn_collector_t *collector, pn_event_type_t type, void *context) { if (!collector) { return NULL; } + assert(context); + pn_event_t *event; if (collector->free_head) { @@ -108,6 +110,8 @@ pn_event_t *pn_collector_put(pn_collecto } event->type = type; + event->context = context; + pn_incref(event->context); return event; } @@ -177,13 +181,6 @@ pn_event_t *pn_event(void) return event; } -void pn_event_init(pn_event_t *event, void *context) -{ - assert(context); - event->context = context; - pn_incref(event->context); -} - pn_event_type_t pn_event_type(pn_event_t *event) { return event->type; @@ -194,6 +191,12 @@ pn_event_category_t pn_event_category(pn return (pn_event_category_t)(event->type & 0x); } +void *pn_event_context
svn commit: r1603953 - in /qpid/proton/trunk/proton-c: include/proton/event.h src/engine/engine-internal.h src/engine/engine.c src/engine/event.c src/messenger/messenger.c
Author: rhs Date: Thu Jun 19 17:22:27 2014 New Revision: 1603953 URL: http://svn.apache.org/r1603953 Log: added PN_{CONNECTION,SESSION,LINK}_FINAL events Modified: qpid/proton/trunk/proton-c/include/proton/event.h qpid/proton/trunk/proton-c/src/engine/engine-internal.h qpid/proton/trunk/proton-c/src/engine/engine.c qpid/proton/trunk/proton-c/src/engine/event.c qpid/proton/trunk/proton-c/src/messenger/messenger.c Modified: qpid/proton/trunk/proton-c/include/proton/event.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/event.h?rev=1603953&r1=1603952&r2=1603953&view=diff == --- qpid/proton/trunk/proton-c/include/proton/event.h (original) +++ qpid/proton/trunk/proton-c/include/proton/event.h Thu Jun 19 17:22:27 2014 @@ -132,7 +132,29 @@ typedef enum { * type point to the relevant transport as well as its associated * connection. */ - PN_TRANSPORT = PN_EVENT_CATEGORY_PROTOCOL+9 + PN_TRANSPORT = PN_EVENT_CATEGORY_PROTOCOL+9, + + /** + * The connection has been freed and any outstanding processing has + * been completed. This is the final event that will ever be issued + * for a connection. + */ + PN_CONNECTION_FINAL = PN_EVENT_CATEGORY_PROTOCOL+10, + + /** + * The session has been freed and any outstanding processing has + * been completed. This is the final event that will ever be issued + * for a session. + */ + PN_SESSION_FINAL = PN_EVENT_CATEGORY_PROTOCOL+11, + + /** + * The link has been freed and any outstanding processing has been + * completed. This is the final event that will ever be issued for a + * link. + */ + PN_LINK_FINAL = PN_EVENT_CATEGORY_PROTOCOL+12 + } pn_event_type_t; /** Modified: qpid/proton/trunk/proton-c/src/engine/engine-internal.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine-internal.h?rev=1603953&r1=1603952&r2=1603953&view=diff == --- qpid/proton/trunk/proton-c/src/engine/engine-internal.h (original) +++ qpid/proton/trunk/proton-c/src/engine/engine-internal.h Thu Jun 19 17:22:27 2014 @@ -51,6 +51,7 @@ struct pn_endpoint_t { pn_endpoint_t *transport_prev; bool modified; bool freed; + bool posted_final; }; typedef struct { Modified: qpid/proton/trunk/proton-c/src/engine/engine.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1603953&r1=1603952&r2=1603953&view=diff == --- qpid/proton/trunk/proton-c/src/engine/engine.c (original) +++ qpid/proton/trunk/proton-c/src/engine/engine.c Thu Jun 19 17:22:27 2014 @@ -348,6 +348,7 @@ void pn_endpoint_init(pn_endpoint_t *end endpoint->transport_prev = NULL; endpoint->modified = false; endpoint->freed = false; + endpoint->posted_final = false; LL_ADD(conn, endpoint, endpoint); } @@ -359,16 +360,39 @@ void pn_endpoint_tini(pn_endpoint_t *end pn_condition_tini(&endpoint->condition); } +#include "event.h" + +static bool pni_post_final(pn_endpoint_t *endpoint, pn_event_type_t type) +{ + pn_connection_t *conn = pn_ep_get_connection(endpoint); + if (!endpoint->posted_final) { +endpoint->posted_final = true; +pn_event_t *event = pn_collector_put(conn->collector, type); +if (event) { + pn_event_init(event, endpoint); + return true; +} + } + + return false; +} + static void pn_connection_finalize(void *object) { pn_connection_t *conn = (pn_connection_t *) object; + + pn_endpoint_t *endpoint = &conn->endpoint; + if (pni_post_final(endpoint, PN_CONNECTION_FINAL)) { +return; + } + pn_free(conn->sessions); pn_free(conn->container); pn_free(conn->hostname); pn_free(conn->offered_capabilities); pn_free(conn->desired_capabilities); pn_free(conn->properties); - pn_endpoint_tini(&conn->endpoint); + pn_endpoint_tini(endpoint); } #define pn_connection_initialize NULL @@ -376,8 +400,6 @@ static void pn_connection_finalize(void #define pn_connection_compare NULL #define pn_connection_inspect NULL -#include "event.h" - pn_connection_t *pn_connection() { static const pn_class_t clazz = PN_CLASS(pn_connection); @@ -687,6 +709,7 @@ pn_link_t *pn_link_next(pn_link_t *link, static void pn_session_finalize(void *object) { pn_session_t *session = (pn_session_t *) object; + pn_endpoint_t *endpoint = &session->endpoint; //pn_transport_t *transport = session->connection->transport; //if (transport) { /* if ((int16_t)session->state.local_channel >= 0) // END not sent */ @@ -695,8 +718,12 @@ static void pn_session_finalize(void *ob /* pn_unmap_channel(transport, session); */ /* } */ + if (pni_post_final(endpoint, PN_SESSION_FINAL)) { +return; + } + pn_free(session->links); - pn_endpoint_tini(&session->endpoint); + pn_endpoint_tini(endpo
svn commit: r1603952 - in /qpid/proton/trunk/proton-c/src/engine: engine.c event.c
Author: rhs Date: Thu Jun 19 17:22:19 2014 New Revision: 1603952 URL: http://svn.apache.org/r1603952 Log: added assert for null event context; fixed pn_collector_pop to decref context prior to adding event back to the free list Modified: qpid/proton/trunk/proton-c/src/engine/engine.c qpid/proton/trunk/proton-c/src/engine/event.c Modified: qpid/proton/trunk/proton-c/src/engine/engine.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1603952&r1=1603951&r2=1603952&view=diff == --- qpid/proton/trunk/proton-c/src/engine/engine.c (original) +++ qpid/proton/trunk/proton-c/src/engine/engine.c Thu Jun 19 17:22:19 2014 @@ -593,7 +593,7 @@ void pn_modified(pn_connection_t *connec pn_incref(endpoint); } - if (emit) { + if (emit && connection->transport) { pn_event_t *event = pn_collector_put(connection->collector, PN_TRANSPORT); if (event) { pn_event_init(event, connection->transport); Modified: qpid/proton/trunk/proton-c/src/engine/event.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/event.c?rev=1603952&r1=1603951&r2=1603952&view=diff == --- qpid/proton/trunk/proton-c/src/engine/event.c (original) +++ qpid/proton/trunk/proton-c/src/engine/event.c Thu Jun 19 17:22:19 2014 @@ -130,14 +130,15 @@ bool pn_collector_pop(pn_collector_t *co collector->tail = NULL; } - event->next = collector->free_head; - collector->free_head = event; - + // decref before adding to the free list if (event->context) { pn_decref(event->context); event->context = NULL; } + event->next = collector->free_head; + collector->free_head = event; + return true; } @@ -178,9 +179,9 @@ pn_event_t *pn_event(void) void pn_event_init(pn_event_t *event, void *context) { + assert(context); event->context = context; - if (event->context) -pn_incref(event->context); + pn_incref(event->context); } pn_event_type_t pn_event_type(pn_event_t *event) - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
svn commit: r1603956 - in /qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl: EndpointImpl.java EventImpl.java
Author: rhs Date: Thu Jun 19 17:22:51 2014 New Revision: 1603956 URL: http://svn.apache.org/r1603956 Log: changed EventImpl to use a single context Modified: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java Modified: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java?rev=1603956&r1=1603955&r2=1603956&view=diff == --- qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java (original) +++ qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java Thu Jun 19 17:22:51 2014 @@ -129,9 +129,12 @@ public abstract class EndpointImpl imple if (emit) { ConnectionImpl conn = getConnectionImpl(); -EventImpl ev = conn.put(Event.Type.TRANSPORT); -if (ev != null) { -ev.init(conn); +TransportImpl trans = conn.getTransport(); +if (trans != null) { +EventImpl ev = conn.put(Event.Type.TRANSPORT); +if (ev != null) { +ev.init(trans); +} } } } Modified: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java?rev=1603956&r1=1603955&r2=1603956&view=diff == --- qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java (original) +++ qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java Thu Jun 19 17:22:51 2014 @@ -36,11 +36,7 @@ class EventImpl implements Event { Type type; -Connection connection; -Session session; -Link link; -Delivery delivery; -Transport transport; +Object context; EventImpl next; EventImpl(Type type) @@ -51,11 +47,7 @@ class EventImpl implements Event void clear() { type = null; -connection = null; -session = null; -link = null; -delivery = null; -transport = null; +context = null; } public Category getCategory() @@ -68,70 +60,91 @@ class EventImpl implements Event return type; } +public Object getContext() +{ +return context; +} + public Connection getConnection() { -return connection; +switch (type) { +case CONNECTION_REMOTE_STATE: +case CONNECTION_LOCAL_STATE: +return (Connection) context; +case TRANSPORT: +Transport transport = getTransport(); +if (transport == null) { +return null; +} +return ((TransportImpl) transport).getConnectionImpl(); +default: +Session ssn = getSession(); +if (ssn == null) { +return null; +} +return ssn.getConnection(); +} } public Session getSession() { -return session; +switch (type) { +case SESSION_REMOTE_STATE: +case SESSION_LOCAL_STATE: +return (Session) context; +default: +Link link = getLink(); +if (link == null) { +return null; +} +return link.getSession(); +} } public Link getLink() { -return link; +switch (type) { +case LINK_REMOTE_STATE: +case LINK_LOCAL_STATE: +case LINK_FLOW: +return (Link) context; +default: +Delivery dlv = getDelivery(); +if (dlv == null) { +return null; +} +return dlv.getLink(); +} } public Delivery getDelivery() { -return delivery; +switch (type) { +case DELIVERY: +return (Delivery) context; +default: +return null; +} } public Transport getTransport() { -return transport; -} - -void init(Transport transport) -{ -this.transport = transport; -} - -void init(Connection connection) -{ -this.connection = connection; -init(((ConnectionImpl) connection).getTransport()); -} - -void init(Session session) -{ -this.session = session; -init(session.getConnection()); -} - -void init(Link link) -{ -this.link = link; -init(link.getSession()); +switch (type
svn commit: r1603954 - /qpid/proton/trunk/proton-c/src/engine/engine.c
Author: rhs Date: Thu Jun 19 17:22:35 2014 New Revision: 1603954 URL: http://svn.apache.org/r1603954 Log: removed unneeded helper function Modified: qpid/proton/trunk/proton-c/src/engine/engine.c Modified: qpid/proton/trunk/proton-c/src/engine/engine.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1603954&r1=1603953&r2=1603954&view=diff == --- qpid/proton/trunk/proton-c/src/engine/engine.c (original) +++ qpid/proton/trunk/proton-c/src/engine/engine.c Thu Jun 19 17:22:35 2014 @@ -59,30 +59,6 @@ static const pn_event_type_t endpoint_ev PN_LINK_LOCAL_STATE,/* SENDER */ PN_LINK_LOCAL_STATE}; /* RECEIVER */ -/* setup the event given the endpoint that generated the event */ -static void endpoint_init_event(pn_event_t *event, -pn_endpoint_t *endpoint) -{ - switch (endpoint->type) { - case CONNECTION: { - pn_connection_t *conn = (pn_connection_t *) endpoint; - pn_event_init(event, conn); -} -break; - case SESSION: { - pn_session_t *ssn = (pn_session_t *) endpoint; - pn_event_init(event, ssn); -} -break; - case SENDER: - case RECEIVER: { - pn_link_t *link = (pn_link_t*) endpoint; - pn_event_init(event, link); -} -break; - } -} - static void pn_endpoint_open(pn_endpoint_t *endpoint) { // TODO: do we care about the current state? @@ -91,7 +67,7 @@ static void pn_endpoint_open(pn_endpoint pn_event_t *event = pn_collector_put(conn->collector, endpoint_event_map[endpoint->type]); if (event) { -endpoint_init_event(event, endpoint); +pn_event_init(event, endpoint); } pn_modified(conn, endpoint, true); } @@ -104,7 +80,7 @@ static void pn_endpoint_close(pn_endpoin pn_event_t *event = pn_collector_put(conn->collector, endpoint_event_map[endpoint->type]); if (event) { -endpoint_init_event(event, endpoint); +pn_event_init(event, endpoint); } pn_modified(conn, endpoint, true); } - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
svn commit: r1603958 - /qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/
Author: rhs Date: Thu Jun 19 17:23:00 2014 New Revision: 1603958 URL: http://svn.apache.org/r1603958 Log: simplified event posting interface Modified: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/CollectorImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SessionImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLink.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSession.java Modified: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/CollectorImpl.java URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/CollectorImpl.java?rev=1603958&r1=1603957&r2=1603958&view=diff == --- qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/CollectorImpl.java (original) +++ qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/CollectorImpl.java Thu Jun 19 17:23:00 2014 @@ -58,18 +58,19 @@ public class CollectorImpl implements Co } } -public EventImpl put(Event.Type type) +public EventImpl put(Event.Type type, Object context) { EventImpl event; if (free == null) { -event = new EventImpl(type); +event = new EventImpl(); } else { event = free; free = free.next; event.next = null; -event.type = type; } +event.init(type, context); + if (head == null) { head = event; tail = event; @@ -77,6 +78,7 @@ public class CollectorImpl implements Co tail.next = event; tail = event; } + return event; } Modified: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java?rev=1603958&r1=1603957&r2=1603958&view=diff == --- qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java (original) +++ qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java Thu Jun 19 17:23:00 2014 @@ -201,10 +201,7 @@ public class ConnectionImpl extends Endp setRemoteDesiredCapabilities(open.getDesiredCapabilities()); setRemoteOfferedCapabilities(open.getOfferedCapabilities()); setRemoteProperties(open.getProperties()); -EventImpl ev = put(Event.Type.CONNECTION_REMOTE_STATE); -if (ev != null) { -ev.init(this); -} +put(Event.Type.CONNECTION_REMOTE_STATE, this); } @@ -573,10 +570,10 @@ public class ConnectionImpl extends Endp _collector = (CollectorImpl) collector; } -EventImpl put(Event.Type type) +EventImpl put(Event.Type type, Object context) { if (_collector != null) { -return _collector.put(type); +return _collector.put(type, context); } else { return null; } @@ -585,9 +582,6 @@ public class ConnectionImpl extends Endp @Override protected void localStateChanged() { -EventImpl ev = put(Event.Type.CONNECTION_LOCAL_STATE); -if (ev != null) { -ev.init(this); -} +put(Event.Type.CONNECTION_LOCAL_STATE, this); } } Modified: qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java?rev=1603958&r1=1603957&r2=1603958&view=diff == --- qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java (original) +++ qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java Thu Jun 19 17:23:00 2014 @@ -131,10 +131,7 @@ public abstract class EndpointImpl imple ConnectionImpl conn = getConnectionImpl(); TransportImpl trans = conn.getTransport(); if (trans != null) { -Even
svn commit: r1603960 - in /qpid/proton/trunk/proton-c: include/proton/object.h src/object/object.c src/tests/object.c
Author: rhs Date: Thu Jun 19 17:23:18 2014 New Revision: 1603960 URL: http://svn.apache.org/r1603960 Log: added new/incref/decref variants that take backpointers for logging; also fixed pn_inspect for pn_hash_t Modified: qpid/proton/trunk/proton-c/include/proton/object.h qpid/proton/trunk/proton-c/src/object/object.c qpid/proton/trunk/proton-c/src/tests/object.c Modified: qpid/proton/trunk/proton-c/include/proton/object.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/object.h?rev=1603960&r1=1603959&r2=1603960&view=diff == --- qpid/proton/trunk/proton-c/include/proton/object.h (original) +++ qpid/proton/trunk/proton-c/include/proton/object.h Thu Jun 19 17:23:18 2014 @@ -43,6 +43,7 @@ typedef void *(*pn_iterator_next_t)(void typedef struct pn_iterator_t pn_iterator_t; typedef struct { + const char *name; void (*initialize)(void *); void (*finalize)(void *); uintptr_t (*hashcode)(void *); @@ -51,6 +52,7 @@ typedef struct { } pn_class_t; #define PN_CLASS(PREFIX) { \ +#PREFIX,\ PREFIX ## _initialize, \ PREFIX ## _finalize,\ PREFIX ## _hashcode,\ @@ -59,9 +61,12 @@ typedef struct { } PN_EXTERN void *pn_new(size_t size, const pn_class_t* clazz); +PN_EXTERN void *pn_new2(size_t size, const pn_class_t* clazz, void *from); PN_EXTERN void pn_initialize(void *object, const pn_class_t *clazz); PN_EXTERN void *pn_incref(void *object); +PN_EXTERN void *pn_incref2(void *object, void *from); PN_EXTERN void pn_decref(void *object); +PN_EXTERN void pn_decref2(void *object, void *from); PN_EXTERN int pn_refcount(void *object); PN_EXTERN void pn_finalize(void *object); PN_EXTERN void pn_free(void *object); Modified: qpid/proton/trunk/proton-c/src/object/object.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/object/object.c?rev=1603960&r1=1603959&r2=1603960&view=diff == --- qpid/proton/trunk/proton-c/src/object/object.c (original) +++ qpid/proton/trunk/proton-c/src/object/object.c Thu Jun 19 17:23:18 2014 @@ -38,6 +38,11 @@ typedef struct { void *pn_new(size_t size, const pn_class_t *clazz) { + return pn_new2(size, clazz, NULL); +} + +void *pn_new2(size_t size, const pn_class_t *clazz, void *from) +{ pni_head_t *head = (pni_head_t *) malloc(sizeof(pni_head_t) + size); void *object = head + 1; pn_initialize(object, clazz); @@ -54,15 +59,22 @@ void pn_initialize(void *object, const p } } -void *pn_incref(void *object) -{ +void *pn_incref(void *object) { + return pn_incref2(object, NULL); +} + +void *pn_incref2(void *object, void *from) { if (object) { pni_head(object)->refcount++; } return object; } -void pn_decref(void *object) +void pn_decref(void *object) { + pn_decref2(object, NULL); +} + +void pn_decref2(void *object, void *from) { if (object) { pni_head_t *head = pni_head(object); @@ -153,13 +165,20 @@ int pn_inspect(void *object, pn_string_t if (object) { pni_head_t *head = pni_head(object); +const char *name; if (head->clazz) { const pn_class_t *clazz = head->clazz; if (clazz->inspect) { return clazz->inspect(object, dst); + } else if (clazz->name) { +name = clazz->name; + } else { +name = "object"; } +} else { + name = "object"; } -return pn_string_addf(dst, "object<%p>", object); +return pn_string_addf(dst, "%s<%p>", name, object); } else { return pn_string_addf(dst, "(null)"); } @@ -188,9 +207,9 @@ void pn_list_set(pn_list_t *list, int in { assert(list); assert(list->size); void *old = list->elements[index % list->size]; - if (list->options & PN_REFCOUNT) pn_decref(old); + if (list->options & PN_REFCOUNT) pn_decref2(old, list); list->elements[index % list->size] = value; - if (list->options & PN_REFCOUNT) pn_incref(value); + if (list->options & PN_REFCOUNT) pn_incref2(value, list); } void pn_list_ensure(pn_list_t *list, size_t capacity) @@ -210,7 +229,7 @@ int pn_list_add(pn_list_t *list, void *v assert(list); pn_list_ensure(list, list->size + 1); list->elements[list->size++] = value; - if (list->options & PN_REFCOUNT) pn_incref(value); + if (list->options & PN_REFCOUNT) pn_incref2(value, list); return 0; } @@ -245,7 +264,7 @@ void pn_list_del(pn_list_t *list, int in if (list->options & PN_REFCOUNT) { for (int i = 0; i < n; i++) { - pn_decref(list->elements[index + i]); + pn_decref2(list->elements[index + i], list); } } @@ -297,7 +316,7 @@ static void pn_list_finalize(void *objec assert(object); pn_list_t *list = (pn_list_t *) object; for (size_t i = 0; i < list->size; i++) { -if (list->options & PN_REFC
svn commit: r1603961 - in /qpid/proton/trunk/proton-c/src: engine/engine.c engine/event.c transport/transport.c
Author: rhs Date: Thu Jun 19 17:23:25 2014 New Revision: 1603961 URL: http://svn.apache.org/r1603961 Log: fixed memory leak by making the transport clean up references held by the channel and handle maps; made use of the backpointer versions of new, incref, and decref to track down issue Modified: qpid/proton/trunk/proton-c/src/engine/engine.c qpid/proton/trunk/proton-c/src/engine/event.c qpid/proton/trunk/proton-c/src/transport/transport.c Modified: qpid/proton/trunk/proton-c/src/engine/engine.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1603961&r1=1603960&r2=1603961&view=diff == --- qpid/proton/trunk/proton-c/src/engine/engine.c (original) +++ qpid/proton/trunk/proton-c/src/engine/engine.c Thu Jun 19 17:23:25 2014 @@ -184,7 +184,7 @@ void pn_add_session(pn_connection_t *con { pn_list_add(conn->sessions, ssn); ssn->connection = conn; - pn_incref(conn); // keep around until finalized + pn_incref2(conn, ssn); // keep around until finalized } void pn_remove_session(pn_connection_t *conn, pn_session_t *ssn) @@ -224,7 +224,7 @@ void pn_session_free(pn_session_t *sessi pn_endpoint_t *endpoint = (pn_endpoint_t *) session; LL_REMOVE(pn_ep_get_connection(endpoint), endpoint, endpoint); session->endpoint.freed = true; - pn_decref(session); + pn_decref2(session, session->connection); } void *pn_session_get_context(pn_session_t *session) @@ -288,10 +288,10 @@ void pn_link_free(pn_link_t *link) while (link->settled_head) { delivery = link->settled_head; LL_POP(link, settled, pn_delivery_t); -pn_decref(delivery); +pn_decref2(delivery, link); } link->endpoint.freed = true; - pn_decref(link); + pn_decref2(link, link->session); } void *pn_link_get_context(pn_link_t *link) @@ -556,7 +556,7 @@ void pn_add_tpwork(pn_delivery_t *delive { LL_ADD(connection, tpwork, delivery); delivery->tpwork = true; -pn_incref(delivery); +pn_incref2(delivery, connection); } pn_modified(connection, &connection->endpoint, true); } @@ -568,7 +568,7 @@ void pn_clear_tpwork(pn_delivery_t *deli { LL_REMOVE(connection, tpwork, delivery); delivery->tpwork = false; -pn_decref(delivery); // may free delivery! +pn_decref2(delivery, connection); // may free delivery! } } @@ -590,7 +590,7 @@ void pn_modified(pn_connection_t *connec if (!endpoint->modified) { LL_ADD(connection, transport, endpoint); endpoint->modified = true; -pn_incref(endpoint); +pn_incref2(endpoint, connection); } if (emit && connection->transport) { @@ -606,7 +606,7 @@ void pn_clear_modified(pn_connection_t * endpoint->transport_next = NULL; endpoint->transport_prev = NULL; endpoint->modified = false; -pn_decref(endpoint); // may free endpoint! +pn_decref2(endpoint, connection); // may free endpoint! } } @@ -704,7 +704,7 @@ static void pn_session_finalize(void *ob pn_delivery_map_free(&session->state.outgoing); pn_free(session->state.local_handles); pn_free(session->state.remote_handles); - pn_decref(session->connection); + pn_decref2(session->connection, session); } #define pn_session_initialize NULL @@ -716,7 +716,7 @@ pn_session_t *pn_session(pn_connection_t { assert(conn); static const pn_class_t clazz = PN_CLASS(pn_session); - pn_session_t *ssn = (pn_session_t *) pn_new(sizeof(pn_session_t), &clazz); + pn_session_t *ssn = (pn_session_t *) pn_new2(sizeof(pn_session_t), &clazz, conn); if (!ssn) return NULL; pn_endpoint_init(&ssn->endpoint, SESSION, conn); @@ -812,7 +812,7 @@ static void pn_link_finalize(void *objec pn_terminus_free(&link->remote_target); pn_free(link->name); pn_endpoint_tini(endpoint); - pn_decref(link->session); + pn_decref2(link->session, link); } #define pn_link_initialize NULL @@ -823,11 +823,11 @@ static void pn_link_finalize(void *objec pn_link_t *pn_link_new(int type, pn_session_t *session, const char *name) { static const pn_class_t clazz = PN_CLASS(pn_link); - pn_link_t *link = (pn_link_t *) pn_new(sizeof(pn_link_t), &clazz); + pn_link_t *link = (pn_link_t *) pn_new2(sizeof(pn_link_t), &clazz, session); pn_endpoint_init(&link->endpoint, type, session->connection); pn_add_link(session, link); - pn_incref(session); // keep session until link finalized + pn_incref2(session, link); // keep session until link finalized link->name = pn_string(name); pn_terminus_init(&link->source, PN_SOURCE); pn_terminus_init(&link->target, PN_TARGET); @@ -1067,7 +1067,7 @@ static void pn_delivery_finalize(void *o pn_buffer_free(delivery->bytes); pn_disposition_finalize(&delivery->local); pn_disposition_finalize(&delivery->remote); - pn_decref(delivery->link); + pn_decref2(delivery->link, delivery); } static void pn_disposition_init(pn_disposition_t *ds) @@ -1102,10 +1102,10 @@ pn
svn commit: r1603959 - in /qpid/proton/trunk: proton-c/bindings/python/ proton-c/include/proton/ proton-c/src/engine/ proton-c/src/messenger/ proton-j/src/main/java/org/apache/qpid/proton/engine/ prot
Author: rhs Date: Thu Jun 19 17:23:10 2014 New Revision: 1603959 URL: http://svn.apache.org/r1603959 Log: added INIT events for endpoints Modified: qpid/proton/trunk/proton-c/bindings/python/proton.py qpid/proton/trunk/proton-c/include/proton/event.h qpid/proton/trunk/proton-c/src/engine/engine.c qpid/proton/trunk/proton-c/src/engine/event.c qpid/proton/trunk/proton-c/src/messenger/messenger.c qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/Event.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SessionImpl.java qpid/proton/trunk/proton-j/src/main/resources/cengine.py qpid/proton/trunk/tests/python/proton_tests/engine.py Modified: qpid/proton/trunk/proton-c/bindings/python/proton.py URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/python/proton.py?rev=1603959&r1=1603958&r2=1603959&view=diff == --- qpid/proton/trunk/proton-c/bindings/python/proton.py (original) +++ qpid/proton/trunk/proton-c/bindings/python/proton.py Thu Jun 19 17:23:10 2014 @@ -3307,13 +3307,19 @@ class Event: CATEGORY_PROTOCOL = PN_EVENT_CATEGORY_PROTOCOL + CONNECTION_INIT = PN_CONNECTION_INIT CONNECTION_LOCAL_STATE = PN_CONNECTION_LOCAL_STATE CONNECTION_REMOTE_STATE = PN_CONNECTION_REMOTE_STATE + CONNECTION_FINAL = PN_CONNECTION_FINAL + SESSION_INIT = PN_SESSION_INIT SESSION_LOCAL_STATE = PN_SESSION_LOCAL_STATE SESSION_REMOTE_STATE = PN_SESSION_REMOTE_STATE + SESSION_FINAL = PN_SESSION_FINAL + LINK_INIT = PN_LINK_INIT LINK_LOCAL_STATE = PN_LINK_LOCAL_STATE LINK_REMOTE_STATE = PN_LINK_REMOTE_STATE LINK_FLOW = PN_LINK_FLOW + LINK_FINAL = PN_LINK_FINAL DELIVERY = PN_DELIVERY TRANSPORT = PN_TRANSPORT Modified: qpid/proton/trunk/proton-c/include/proton/event.h URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/include/proton/event.h?rev=1603959&r1=1603958&r2=1603959&view=diff == --- qpid/proton/trunk/proton-c/include/proton/event.h (original) +++ qpid/proton/trunk/proton-c/include/proton/event.h Thu Jun 19 17:23:10 2014 @@ -153,7 +153,25 @@ typedef enum { * completed. This is the final event that will ever be issued for a * link. */ - PN_LINK_FINAL = PN_EVENT_CATEGORY_PROTOCOL+12 + PN_LINK_FINAL = PN_EVENT_CATEGORY_PROTOCOL+12, + + /** + * The connection has been created. This is the first event that + * will ever be issued for a connection. + */ + PN_CONNECTION_INIT = PN_EVENT_CATEGORY_PROTOCOL+13, + + /** + * The session has been created. This is the first event that will + * ever be issued for a session. + */ + PN_SESSION_INIT = PN_EVENT_CATEGORY_PROTOCOL+14, + + /** + * The link has been created. This is the first event that will ever + * be issued for a link. + */ + PN_LINK_INIT = PN_EVENT_CATEGORY_PROTOCOL+15 } pn_event_type_t; Modified: qpid/proton/trunk/proton-c/src/engine/engine.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/engine.c?rev=1603959&r1=1603958&r2=1603959&view=diff == --- qpid/proton/trunk/proton-c/src/engine/engine.c (original) +++ qpid/proton/trunk/proton-c/src/engine/engine.c Thu Jun 19 17:23:10 2014 @@ -395,9 +395,20 @@ pn_connection_t *pn_connection() return conn; } +static const pn_event_type_t endpoint_init_event_map[] = { + PN_CONNECTION_INIT, /* CONNECTION */ + PN_SESSION_INIT, /* SESSION */ + PN_LINK_INIT,/* SENDER */ + PN_LINK_INIT}; /* RECEIVER */ + void pn_connection_collect(pn_connection_t *connection, pn_collector_t *collector) { connection->collector = collector; + pn_endpoint_t *endpoint = connection->endpoint_head; + while (endpoint) { +pn_collector_put(connection->collector, endpoint_init_event_map[endpoint->type], endpoint); +endpoint = endpoint->endpoint_next; + } } pn_state_t pn_connection_state(pn_connection_t *connection) @@ -728,6 +739,7 @@ pn_session_t *pn_session(pn_connection_t ssn->state.remote_handles = pn_hash(0, 0.75, PN_REFCOUNT); // end transport state + pn_collector_put(conn->collector, PN_SESSION_INIT, ssn); return ssn; } @@ -841,8 +853,9 @@ pn_link_t *pn_link_new(int type, pn_sess link->state.remote_handle = -1; link->state.delivery_count = 0; link->state.link_credit = 0; - // end transport stat + // end transport state + pn_collector_put(session->connection->collector, PN_LINK_INIT, link); return link; } Modified: qpid/proton/trunk/proton-c/src/engine/event.c URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/src/engine/event.c?rev=1
svn commit: r1603963 - in /qpid/proton/trunk: proton-c/bindings/python/ proton-j/src/main/java/org/apache/qpid/proton/engine/ proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ proton-j/src/ma
Author: rhs Date: Thu Jun 19 17:23:39 2014 New Revision: 1603963 URL: http://svn.apache.org/r1603963 Log: implemented final events for proton-j; added tests for final events Modified: qpid/proton/trunk/proton-c/bindings/python/proton.py qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/Transport.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ConnectionImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EndpointImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/EventImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/LinkImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/ReceiverImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SenderImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/SessionImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportImpl.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportLink.java qpid/proton/trunk/proton-j/src/main/java/org/apache/qpid/proton/engine/impl/TransportSession.java qpid/proton/trunk/proton-j/src/main/resources/cengine.py qpid/proton/trunk/tests/python/proton_tests/engine.py Modified: qpid/proton/trunk/proton-c/bindings/python/proton.py URL: http://svn.apache.org/viewvc/qpid/proton/trunk/proton-c/bindings/python/proton.py?rev=1603963&r1=1603962&r2=1603963&view=diff == --- qpid/proton/trunk/proton-c/bindings/python/proton.py (original) +++ qpid/proton/trunk/proton-c/bindings/python/proton.py Thu Jun 19 17:23:39 2014 @@ -2178,6 +2178,16 @@ class Endpoint(object): def __init__(self): self.condition = None +self._release_invoked = False + + def _release(self): +"""Release the underlying C Engine resource.""" +if not self._release_invoked: + for c in self._children: +c._release() + self._free_resource() + self.connection._releasing(self) + self._release_invoked = True def _update_cond(self): obj2cond(self.condition, self._get_cond_impl()) @@ -2269,13 +2279,31 @@ class Connection(Endpoint): def __del__(self): if hasattr(self, "_conn") and self._conn: - # pn_connection_free will release all child sessions in the C Engine, so - # free all child python Sessions to avoid dangling references - if hasattr(self, "_sessions") and self._sessions: -for s in self._sessions: - s._release() - pn_connection_set_context(self._conn, None) - pn_connection_free(self._conn) + self._release() + + def free(self): +self._release() + + @property + def _children(self): +return self._sessions + + @property + def connection(self): +return self + + def _free_resource(self): +pn_connection_free(self._conn) + + def _released(self): +self._conn = None + + def _releasing(self, child): +coll = getattr(self, "_collector", None) +if coll: + coll._contexts.add(child) +else: + child._released() def _check(self, err): if err < 0: @@ -2389,16 +2417,15 @@ class Session(Endpoint): self._links = set() self.connection._sessions.add(self) - def _release(self): -"""Release the underlying C Engine resource.""" -if self._ssn: - # pn_session_free will release all child links in the C Engine, so free - # all child python Links to avoid dangling references - for l in self._links: -l._release() - pn_session_set_context(self._ssn, None) - pn_session_free(self._ssn) - self._ssn = None + @property + def _children(self): +return self._links + + def _free_resource(self): +pn_session_free(self._ssn) + + def _released(self): +self._ssn = None def free(self): """Release the Session, freeing its resources. @@ -2490,16 +2517,15 @@ class Link(Endpoint): self._deliveries = set() self.session._links.add(self) - def _release(self): -"""Release the underlying C Engine resource.""" -if self._link: - # pn_link_free will settle all child deliveries in the C Engine, so free - # all child python deliveries to avoid dangling references - for d in self._deliveries: -d._release() - pn_link_set_context(self._link, None) - pn_link_free(self._link) - self._link = None + @property + def _children(self): +return self._deliveries + + def _free_resource(self): +pn_link_free(self._link) + + def _released(self): +self._link = None def free(self): """Release the Link, freeing its resources""" @@ -2549,6 +2575,10 @@ class Link(Endpoint): def session(self): return Session._wrap_session(pn_link_session(self._link)) + @proper
svn commit: r1604037 - /qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCConfigurationStore.java
Author: kwall Date: Thu Jun 19 21:31:51 2014 New Revision: 1604037 URL: http://svn.apache.org/r1604037 Log: QPID-5800: [Java Broker] Defect - prevent JDBC upgrader on throwing exception due to open transaction causing exception to log Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCConfigurationStore.java Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCConfigurationStore.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCConfigurationStore.java?rev=1604037&r1=1604036&r2=1604037&view=diff == --- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCConfigurationStore.java (original) +++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/AbstractJDBCConfigurationStore.java Thu Jun 19 21:31:51 2014 @@ -226,7 +226,7 @@ public abstract class AbstractJDBCConfig Connection connection = null; try { -connection = newConnection(); +connection = newAutoCommitConnection(); boolean tableExists = tableExists(CONFIGURATION_VERSION_TABLE_NAME, connection); if(tableExists) - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org
svn commit: r1604036 - in /qpid/trunk/qpid/java/broker-core/src: main/java/org/apache/qpid/server/store/JsonFileConfigStore.java test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStor
Author: kwall Date: Thu Jun 19 21:31:23 2014 New Revision: 1604036 URL: http://svn.apache.org/r1604036 Log: QPID-5819: Make JsonFileConfigStore#close idempotent, like other DCS implementations Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java Modified: qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java?rev=1604036&r1=1604035&r2=1604036&view=diff == --- qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java (original) +++ qpid/trunk/qpid/java/broker-core/src/main/java/org/apache/qpid/server/store/JsonFileConfigStore.java Thu Jun 19 21:31:23 2014 @@ -564,17 +564,11 @@ public class JsonFileConfigStore impleme { releaseFileLock(); } -catch (IOException e) -{ -throw new StoreException("Failed to release lock", e); -} finally { -_fileLock = null; _idsByType.clear(); _objectsById.clear(); } - } @Override @@ -588,13 +582,26 @@ public class JsonFileConfigStore impleme } } -private void releaseFileLock() throws IOException +private void releaseFileLock() { -_fileLock.release(); -_fileLock.channel().close(); +if (_fileLock != null) +{ +try +{ +_fileLock.release(); +_fileLock.channel().close(); +} +catch (IOException e) +{ +throw new StoreException("Failed to release lock " + _fileLock, e); +} +finally +{ +_fileLock = null; +} +} } - private static Map> generateClassNameMap(final Model model, final Class clazz) { Modified: qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java?rev=1604036&r1=1604035&r2=1604036&view=diff == --- qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java (original) +++ qpid/trunk/qpid/java/broker-core/src/test/java/org/apache/qpid/server/store/AbstractDurableConfigurationStoreTestCase.java Thu Jun 19 21:31:23 2014 @@ -64,8 +64,6 @@ import org.apache.qpid.util.FileUtils; public abstract class AbstractDurableConfigurationStoreTestCase extends QpidTestCase { -private static final String EXCHANGE_NAME = "exchangeName"; - private static final String EXCHANGE = org.apache.qpid.server.model.Exchange.class.getSimpleName(); private static final String BINDING = org.apache.qpid.server.model.Binding.class.getSimpleName(); private static final String QUEUE = Queue.class.getSimpleName(); @@ -139,6 +137,13 @@ public abstract class AbstractDurableCon } } +public void testCloseIsIdempotent() throws Exception +{ +_configStore.closeConfigurationStore(); +// Second close should be accepted without exception +_configStore.closeConfigurationStore(); +} + public void testCreateExchange() throws Exception { ExchangeImpl exchange = createTestExchange(); - To unsubscribe, e-mail: commits-unsubscr...@qpid.apache.org For additional commands, e-mail: commits-h...@qpid.apache.org