Skip to content

Commit 92f3f38

Browse files
committed
wl#9819 patch #2 : Misc. housekeeping required for worklog
(A) move ndb_basename into utility library (B) new portability function ndb_getsockname()
1 parent f51bd28 commit 92f3f38

File tree

6 files changed

+59
-25
lines changed

6 files changed

+59
-25
lines changed

storage/ndb/include/portlib/ndb_socket_posix.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -201,6 +201,15 @@ int my_getpeername(ndb_socket_t s, struct sockaddr *a, socket_len_t *addrlen)
201201
return 0;
202202
}
203203

204+
static inline
205+
int ndb_getsockname(ndb_socket_t s, struct sockaddr *a, socket_len_t *addrlen)
206+
{
207+
if(getsockname(s.fd, a, addrlen))
208+
return 1;
209+
210+
return 0;
211+
}
212+
204213
static inline int my_shutdown(ndb_socket_t s, int how)
205214
{
206215
return shutdown(s.fd, how);

storage/ndb/include/portlib/ndb_socket_win32.h

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2008, 2015, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2008, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -192,6 +192,15 @@ static inline int my_getpeername(ndb_socket_t s, struct sockaddr *a,
192192
return 0;
193193
}
194194

195+
static inline int ndb_getsockname(ndb_socket_t s, struct sockaddr *a,
196+
socket_len_t *addrlen)
197+
{
198+
if(getsockname(s.s, a, addrlen))
199+
return 1;
200+
201+
return 0;
202+
}
203+
195204
static inline int my_shutdown(ndb_socket_t s, int how)
196205
{
197206
return shutdown(s.s, how);

storage/ndb/src/common/portlib/ndb_socket.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved.
2+
Copyright (c) 2009, 2016, Oracle and/or its affiliates. All rights reserved.
33
44
This program is free software; you can redistribute it and/or modify
55
it under the terms of the GNU General Public License as published by
@@ -79,11 +79,7 @@ int my_socketpair(ndb_socket_t s[2])
7979
goto err;
8080

8181
/* get sockname */
82-
/*
83-
TODO: if there was a my_getsockname, this wouldnt have to use
84-
definition of my_socket (i.e l.s)
85-
*/
86-
if (getsockname(listener.s, (struct sockaddr*)&addr, &addrlen) < 0)
82+
if (ndb_getsockname(listener, (struct sockaddr*)&addr, &addrlen) != 0)
8783
goto err;
8884

8985
if (my_listen(listener, 1) == -1)

storage/ndb/src/common/util/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ ADD_DEFINITIONS(-DNO_DUMMY_DECL)
2828
ADD_CONVENIENCE_LIBRARY(ndbgeneral
2929
ndbzio.c
3030
File.cpp
31+
basename.cpp
3132
md5_hash.cpp
3233
Properties.cpp
3334
socket_io.cpp
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
/*
2+
Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
3+
4+
This program is free software; you can redistribute it and/or modify
5+
it under the terms of the GNU General Public License as published by
6+
the Free Software Foundation; version 2 of the License.
7+
8+
This program is distributed in the hope that it will be useful,
9+
but WITHOUT ANY WARRANTY; without even the implied warranty of
10+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11+
GNU General Public License for more details.
12+
13+
You should have received a copy of the GNU General Public License
14+
along with this program; if not, write to the Free Software
15+
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
16+
*/
17+
18+
#include <ndb_global.h>
19+
20+
const char *
21+
ndb_basename(const char * path)
22+
{
23+
if (path == NULL)
24+
return NULL;
25+
26+
const char separator = '/';
27+
const char * p = path + strlen(path);
28+
while (p > path && p[0] != separator)
29+
p--;
30+
31+
if (p[0] == separator)
32+
return p + 1;
33+
34+
return p;
35+
}

storage/ndb/src/kernel/error/ErrorReporter.cpp

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -54,23 +54,7 @@ static void dumpJam(FILE* jamStream,
5454
Uint32 thrdTheEmulatedJamIndex,
5555
const JamEvent thrdTheEmulatedJam[]);
5656

57-
static
58-
const char *
59-
ndb_basename(const char * path)
60-
{
61-
if (path == NULL)
62-
return NULL;
63-
64-
const char separator = '/';
65-
const char * p = path + strlen(path);
66-
while (p > path && p[0] != separator)
67-
p--;
68-
69-
if (p[0] == separator)
70-
return p + 1;
71-
72-
return p;
73-
}
57+
const char * ndb_basename(const char *path);
7458

7559
static
7660
const char*

0 commit comments

Comments
 (0)