MCPcopy Create free account
hub / github.com/apache/brpc / StartDummyServerAt

Function StartDummyServerAt

src/brpc/server.cpp:1930–1958  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1928static Server* g_dummy_server = NULL;
1929
1930int StartDummyServerAt(int port, ProfilerLinker) {
1931 if (port < 0 || port >= 65536) {
1932 LOG(ERROR) << "Invalid port=" << port;
1933 return -1;
1934 }
1935 if (g_dummy_server == NULL) { // (1)
1936 BAIDU_SCOPED_LOCK(g_dummy_server_mutex);
1937 if (g_dummy_server == NULL) {
1938 Server* dummy_server = new Server;
1939 dummy_server->set_version(butil::string_printf(
1940 "DummyServerOf(%s)", GetProgramName()));
1941 ServerOptions options;
1942 options.num_threads = 0;
1943 options.bthread_tag = bthread_self_tag();
1944 if (dummy_server->Start(port, &options) != 0) {
1945 LOG(ERROR) << "Fail to start dummy_server at port=" << port;
1946 return -1;
1947 }
1948 // (1) may see uninitialized dummy_server due to relaxed memory
1949 // fencing, but we only expose a function to test existence
1950 // of g_dummy_server, everything should be fine.
1951 g_dummy_server = dummy_server;
1952 return 0;
1953 }
1954 }
1955 LOG(ERROR) << "Already have dummy_server at port="
1956 << g_dummy_server->listen_address().port;
1957 return -1;
1958}
1959
1960bool IsDummyServerRunning() {
1961 return g_dummy_server != NULL;

Callers 12

mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
GlobalUpdateFunction · 0.85

Calls 6

string_printfFunction · 0.85
GetProgramNameFunction · 0.85
bthread_self_tagFunction · 0.85
listen_addressMethod · 0.80
set_versionMethod · 0.45
StartMethod · 0.45

Tested by

no test coverage detected