nifi-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [nifi-minifi-cpp] bakaid commented on a change in pull request #713: MINIFICPP-1119 unify win/posix sockets + clean up issues
Date Mon, 10 Feb 2020 17:07:07 GMT
bakaid commented on a change in pull request #713: MINIFICPP-1119 unify win/posix sockets +
clean up issues
URL: https://github.com/apache/nifi-minifi-cpp/pull/713#discussion_r377165778
 
 

 ##########
 File path: libminifi/src/io/ClientSocket.cpp
 ##########
 @@ -51,50 +50,57 @@ namespace nifi {
 namespace minifi {
 namespace io {
 
-Socket::Socket(const std::shared_ptr<SocketContext> &context, const std::string
&hostname, const uint16_t port, const uint16_t listeners = -1)
-    : requested_hostname_(hostname),
+static std::string get_last_err_str() noexcept {
+#ifdef WIN32
+  const auto error_code = WSAGetLastError();
+#else
+  const auto error_code = errno;
+#endif /* WIN32 */
+  return std::system_category().message(error_code);
+}
+
+static bool valid_sock_fd(SocketDescriptor fd) {
+#ifdef WIN32
+  return fd != INVALID_SOCKET && fd >= 0;
+#else
+  return fd >= 0;
+#endif /* WIN32 */
+}
+
+Socket::Socket(const std::shared_ptr<SocketContext>& /*context*/, std::string hostname,
const uint16_t port, const uint16_t listeners)
+    : requested_hostname_(std::move(hostname)),
       port_(port),
-      socket_file_descriptor_(-1),
-      socket_max_(0),
-      total_written_(0),
-      total_read_(0),
-      is_loopback_only_(false),
       listeners_(listeners),
-      canonical_hostname_(""),
-      nonBlocking_(false),
       logger_(logging::LoggerFactory<Socket>::getLogger()) {
   FD_ZERO(&total_list_);
   FD_ZERO(&read_fds_);
   initialize_socket();
 }
 
-Socket::Socket(const std::shared_ptr<SocketContext> &context, const std::string
&hostname, const uint16_t port)
-    : Socket(context, hostname, port, 0) {
-  initialize_socket();
+Socket::Socket(const std::shared_ptr<SocketContext>& context, std::string hostname,
const uint16_t port)
+    : Socket(context, std::move(hostname), port, 0) {
 }
 
-Socket::Socket(const Socket &&other)
+Socket::Socket(Socket &&other) noexcept
 
 Review comment:
   This ignores a bunch of data members.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message