phrocker commented on a change in pull request #558: MINIFICPP-542 - Add PutSFTP processor URL: https://github.com/apache/nifi-minifi-cpp/pull/558#discussion_r285070214
########## File path: extensions/sftp/client/SFTPClient.h ########## @@ -0,0 +1,183 @@ +/** + * + * 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. + */ +#ifndef __SFTP_CLIENT_H__ +#define __SFTP_CLIENT_H__ + +#include <curl/curl.h> +#include <libssh2.h> +#include <libssh2_sftp.h> +#include <vector> +#include <iostream> +#include <string> +#include <uuid/uuid.h> +#include <vector> + +#include "utils/HTTPClient.h" +#include "core/logging/Logger.h" +#include "core/logging/LoggerConfiguration.h" +#include "properties/Configure.h" +#include "io/validation.h" +#include "io/BaseStream.h" + +namespace org { +namespace apache { +namespace nifi { +namespace minifi { +namespace utils { + +/** + * Initializes and cleans up curl and libssh2 once. + * Cleanup will only occur at the end of our execution since we are relying on a static variable. + */ +class SFTPClientInitializer { + public: + static SFTPClientInitializer *getInstance() { + static SFTPClientInitializer initializer; + return &initializer; + } + void initialize() { + + } + private: + SFTPClientInitializer() { + libssh2_init(0); + curl_global_init(CURL_GLOBAL_DEFAULT); Review comment: curl_global_init is not thread safe. The singleton pattern appears to model that which is in http-curl, which is lazily initialized. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
