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

Function RegisterChecksumHandler

src/brpc/checksum.cpp:28–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

26static ChecksumHandler s_handler_map[MAX_HANDLER_SIZE] = {{NULL, NULL, NULL}};
27
28int RegisterChecksumHandler(ChecksumType type, ChecksumHandler handler) {
29 if (NULL == handler.Compute) {
30 LOG(FATAL) << "Invalid parameter: handler function is NULL";
31 return -1;
32 }
33 int index = type;
34 if (index < 0 || index >= MAX_HANDLER_SIZE) {
35 LOG(FATAL) << "ChecksumType=" << type << " is out of range";
36 return -1;
37 }
38 if (s_handler_map[index].Compute != NULL) {
39 LOG(FATAL) << "ChecksumType=" << type << " was registered";
40 return -1;
41 }
42 s_handler_map[index] = handler;
43 return 0;
44}
45
46// Find ChecksumHandler by type.
47// Returns NULL if not found

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected