Github user littletiny commented on the pull request:
https://github.com/apache/thrift/pull/315#issuecomment-66949477
the c++ version in directory contrib/zeromq override wrong interface
in TZmqClient.h
TZmqClient inherit from TTransport
TTransport provide these method:
// these two methods is not virtual !
read
write
// these tow methods is virtual
read_virt
write_virt
But in TZmqClient.h
we can see
TZmqClient override read and write methods
in test-client.cpp:
use TBinaryProtocol as the protocol
···
zmq::context_t ctx(1);
shared_ptr<TZmqClient> transport(new TZmqClient(ctx, endpoint, socktype));
shared_ptr<TBinaryProtocol> protocol(new TBinaryProtocol(transport));
StorageClient client(protocol);
transport->open();
if (incr) {
client.incr(incr);
usleep(50000);
} else {
int value = client.get();
std::cout << value << std::endl;
}
···
now client is a StorageClient object
client.incr callgraph :
StorageClient::incr-> StorageClient::send_incr ->
TBinaryProtocol::WriteMessageBegin -> TBinaryProtocol::writeI32 ->
TTransport::write
but TTransport::write is not a virtual method, it call
TTransport::write_virt, this is the real virtual methods
in class TZmqClient, we override it cannot take effect
we need to override TTransport::write_virt
---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---