You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Peace C (JIRA)" <ji...@apache.org> on 2012/10/05 20:34:03 UTC

[jira] [Comment Edited] (THRIFT-1558) Named Pipe and Anonymous Pipe transport for Windows

    [ https://issues.apache.org/jira/browse/THRIFT-1558?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13470000#comment-13470000 ] 

Peace C edited comment on THRIFT-1558 at 10/5/12 6:33 PM:
----------------------------------------------------------

Jens - thanks for catching this. You're right the NULL assignment is incorrect. Please test out this patch (it's simply removing the line sa.lpSecurityDescriptor = NULL), it works with my sample project.
                
      was (Author: peace):
    Jens - thanks for catching this. Please replace the following in TCreateAnonPipe:

  InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
  SetSecurityDescriptorDacl(&sd, true, NULL, false);
  sa.lpSecurityDescriptor = &sd;
  sa.lpSecurityDescriptor = NULL;

with

  &sd = NULL;
  InitializeSecurityDescriptor(&sd,SECURITY_DESCRIPTOR_REVISION);
  SetSecurityDescriptorDacl(&sd, true, NULL, false);
  sa.lpSecurityDescriptor = &sd;


If this works, would you mind creating a patch and attaching to this issue? I'm hoping the fix can still make it into Thrift 0.9.
                  
> Named Pipe and Anonymous Pipe transport for Windows
> ---------------------------------------------------
>
>                 Key: THRIFT-1558
>                 URL: https://issues.apache.org/jira/browse/THRIFT-1558
>             Project: Thrift
>          Issue Type: New Feature
>          Components: C++ - Library
>    Affects Versions: 0.9
>         Environment: Microsoft Windows / Visual Studio
>            Reporter: Peace C
>            Assignee: Roger Meier
>              Labels: anonymous, named, pipe, thrift, transport
>         Attachments: AnonPipe.patch, Pipe_snippets.cpp, Thrift-1558_xplatform_pipe_6-5-2012.patch, Thrift_Named_Pipe_Transport_Windows.patch, Thrift_transport_sample.patch
>
>
> This patch adds named & anonymous pipe transport for Windows. The new classes do not affect *NIX builds. We've been using this code on Windows & OSX for 6 months and I'm fairly confident in it. It has not been hammered by automated tests and I welcome stress testing to wring out any bugs.
> The TPipe and TPipeServer classes are generally modeled after TSocket and TSocketServer. The server of course uses TPipeServer to set up the server side then instantiates TPipe for communications. The client instantiates TPipe transport for connection to the server.
> Here are some code snippet examples from functions we've built. Variables such as 'pipename' are passed in to the functions. Error handling has been omitted.
> //-----------------------------------------------------------------------
> // ---- Server ----
> //-----------------------------------------------------------------------
> #ifdef _WIN32
> 	pipename = "\\\\.\\pipe\\" + pipename;
> 	boost::shared_ptr<TServerTransport> transport(new TPipeServer(pipename, 1024, NumThreads)); //Named pipe
> #else  //Mac, *NIX
> 	unlink(pipename.c_str());
> 	boost::shared_ptr<TServerTransport> transport(new TServerSocket(pipename));
> #endif
> 	boost::shared_ptr<TServer> server;
> 	boost::shared_ptr<MyHandler> handler(new MyHandler());
> 	boost::shared_ptr<TProcessor> processor(new MyProcessor(handler));
> 	boost::shared_ptr<TTransportFactory> tfactory(new TBufferedTransportFactory());
> 	boost::shared_ptr<TProtocolFactory> pfactory(new TBinaryProtocolFactory());
> 	if(NumThreads <= 1)
> 	{	//Single-threaded server
> 		server.reset(new TSimpleServer(processor, transport, tfactory, pfactory));
> 	}
> 	else
> 	{	//Multi-threaded server
> 		boost::shared_ptr<ThreadManager> threadManager = ThreadManager::newSimpleThreadManager(NumThreads);
> 		boost::shared_ptr<PlatformThreadFactory> threadFactory = boost::shared_ptr<PlatformThreadFactory>(new PlatformThreadFactory());
> 		threadManager->threadFactory(threadFactory);
> 		threadManager->start();
> 		server.reset(new TThreadPoolServer(processor, transport, tfactory, pfactory, threadManager));
> 	}
> 	printf("Starting the 'server'...\n");
> 	server->serve();
> 	printf("done.\n");
> //-----------------------------------------------------------------------
> // ---- Client ----
> //-----------------------------------------------------------------------
> #ifdef _WIN32
> 	pipename = "\\\\.\\pipe\\" + pipename;
> 	boost::shared_ptr<TTransport> pipe(new TPipe(pipename));
> 	transport.reset(new TBufferedTransport(pipe));
> #else  //Mac, *nix
> 	boost::shared_ptr<TTransport> socket(new TSocket(pipename));
> 	transport.reset(new TBufferedTransport(socket));
> #endif
> 	boost::shared_ptr<TProtocol> protocol(new TBinaryProtocol(transport));
> 	client.reset(new MyClient(protocol));

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira