Files
scylladb/redis/server.hh
Kefu Chai af5674211d redis/server.hh: suppress -Wimplicit-fallthrough from protocol_parser.hh
when compiling the tree with clang-18 and ragel 6.10, the compiler
warns like:

```
/usr/local/bin/cmake -E __run_co_compile --tidy="clang-tidy-18;--checks=-*,bugprone-use-after-move;--extra-arg-before=--driver-mode=g++" --source=/home/runner/work/scylladb/scylladb/redis/controller.cc -- /usr/bin/clang++-18 -DBOOST_NO_CXX98_FUNCTION_BASE -DSCYLLA_BUILD_MODE=release -DSEASTAR_API_LEVEL=7 -DSEASTAR_LOGGER_COMPILE_TIME_FMT -DSEASTAR_LOGGER_TYPE_STDOUT -DSEASTAR_SCHEDULING_GROUPS_COUNT=16 -DSEASTAR_SSTRING -DXXH_PRIVATE_API -I/home/runner/work/scylladb/scylladb -I/home/runner/work/scylladb/scylladb/build/gen -I/home/runner/work/scylladb/scylladb/seastar/include -I/home/runner/work/scylladb/scylladb/build/seastar/gen/include -I/home/runner/work/scylladb/scylladb/build/seastar/gen/src -isystem /home/runner/work/scylladb/scylladb/cooking/include -ffunction-sections -fdata-sections -O3 -g -gz -std=gnu++20 -fvisibility=hidden -Wall -Werror -Wextra -Wno-error=deprecated-declarations -Wimplicit-fallthrough -Wno-c++11-narrowing -Wno-deprecated-copy -Wno-mismatched-tags -Wno-missing-field-initializers -Wno-overloaded-virtual -Wno-unsupported-friend -Wno-enum-constexpr-conversion -Wno-unused-parameter -ffile-prefix-map=/home/runner/work/scylladb/scylladb=. -march=westmere -mllvm -inline-threshold=2500 -fno-slp-vectorize -U_FORTIFY_SOURCE -Werror=unused-result -MD -MT redis/CMakeFiles/redis.dir/controller.cc.o -MF redis/CMakeFiles/redis.dir/controller.cc.o.d -o redis/CMakeFiles/redis.dir/controller.cc.o -c /home/runner/work/scylladb/scylladb/redis/controller.cc
error: too many errors emitted, stopping now [clang-diagnostic-error]
Error: /home/runner/work/scylladb/scylladb/build/gen/redis/protocol_parser.hh:110:1: error: unannotated fall-through between switch labels [clang-diagnostic-implicit-fallthrough]
  110 | case 1:
      | ^
/home/runner/work/scylladb/scylladb/build/gen/redis/protocol_parser.hh:110:1: note: insert 'FMT_FALLTHROUGH;' to silence this warning
  110 | case 1:
      | ^
      | FMT_FALLTHROUGH;
```

since we have `-Werror`, the warnings like this are considered as error,
hence the build fails. in order to address this failure, let's silence
this warning when including this generated header file.

Signed-off-by: Kefu Chai <kefu.chai@scylladb.com>

Closes scylladb/scylladb#18447
2024-05-01 18:47:24 +03:00

106 lines
3.2 KiB
C++

/*
* Copyright (C) 2019 pengjian.uestc @ gmail.com
*/
/*
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
#pragma once
#include "redis/options.hh"
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wimplicit-fallthrough"
#include "redis/protocol_parser.hh"
#pragma GCC diagnostic pop
#include "redis/query_processor.hh"
#include "redis/reply.hh"
#include "redis/request.hh"
#include "redis/stats.hh"
#include "auth/service.hh"
#include "service_permit.hh"
#include "timeout_config.hh"
#include "generic_server.hh"
#include <seastar/core/seastar.hh>
#include <seastar/core/semaphore.hh>
#include <seastar/core/sharded.hh>
#include <seastar/core/execution_stage.hh>
#include <seastar/net/tls.hh>
#include <memory>
db::consistency_level make_consistency_level(const sstring&);
class redis_exception;
namespace service {
class storage_proxy;
}
namespace redis_transport {
struct redis_server_config {
::updateable_timeout_config _timeout_config;
size_t _max_request_size;
db::consistency_level _read_consistency_level;
db::consistency_level _write_consistency_level;
size_t _total_redis_db_count;
};
class redis_server : public generic_server::server {
seastar::sharded<redis::query_processor>& _query_processor;
redis_server_config _config;
size_t _max_request_size;
semaphore _memory_available;
redis::stats _stats;
auth::service& _auth_service;
size_t _total_redis_db_count;
public:
redis_server(seastar::sharded<redis::query_processor>& qp, auth::service& auth_service, redis_server_config config);
struct result {
result(redis::redis_message&& m) : _data(make_foreign(std::make_unique<redis::redis_message>(std::move(m)))) {}
foreign_ptr<std::unique_ptr<redis::redis_message>> _data;
inline lw_shared_ptr<scattered_message<char>> make_message() {
return _data->message();
}
};
using response_type = result;
private:
class connection : public generic_server::connection {
redis_server& _server;
socket_address _server_addr;
redis_protocol_parser _parser;
redis::redis_options _options;
using execution_stage_type = inheriting_concrete_execution_stage<
future<redis_server::result>,
redis_server::connection*,
redis::request&&,
redis::redis_options&,
service_permit
>;
static thread_local execution_stage_type _process_request_stage;
public:
connection(redis_server& server, socket_address server_addr, connected_socket&& fd, socket_address addr);
virtual ~connection();
future<> process_request() override;
void handle_error(future<>&& f) override;
void write_reply(const redis_exception&);
void write_reply(redis_server::result result);
private:
future<result> process_request_one(redis::request&& request, redis::redis_options&, service_permit permit);
future<result> process_request_internal();
};
virtual shared_ptr<generic_server::connection> make_connection(socket_address server_addr, connected_socket&& fd, socket_address addr) override;
future<> unadvertise_connection(shared_ptr<generic_server::connection> conn) override;
};
}