Fix some old license headers
[folly.git] / folly / io / async / EventHandler.cpp
index 67d15889136eb2a649d859989278f55ea31bb6a4..af1d17e88fbb3af70eb3ff0e1d6428ff366fac8c 100644 (file)
@@ -1,23 +1,19 @@
 /*
- * Copyright 2016 Facebook, Inc.
+ * Copyright 2004-present Facebook, Inc.
  *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
  *
  *   http://www.apache.org/licenses/LICENSE-2.0
  *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
  */
+
 #include <folly/io/async/EventHandler.h>
 #include <folly/io/async/EventBase.h>
 
@@ -26,7 +22,7 @@
 namespace folly {
 
 EventHandler::EventHandler(EventBase* eventBase, int fd) {
-  event_set(&event_, fd, 0, &EventHandler::libeventCallback, this);
+  folly_event_set(&event_, fd, 0, &EventHandler::libeventCallback, this);
   if (eventBase != nullptr) {
     setEventBase(eventBase);
   } else {
@@ -62,8 +58,12 @@ bool EventHandler::registerImpl(uint16_t events, bool internal) {
   // Unfortunately, event_set() resets the event_base, so we have to remember
   // it before hand, then pass it back into event_base_set() afterwards
   struct event_base* evb = event_.ev_base;
-  event_set(&event_, event_.ev_fd, events,
-            &EventHandler::libeventCallback, this);
+  event_set(
+      &event_,
+      event_.ev_fd,
+      short(events),
+      &EventHandler::libeventCallback,
+      this);
   event_base_set(evb, &event_);
 
   // Set EVLIST_INTERNAL if this is an internal event
@@ -124,13 +124,13 @@ void EventHandler::changeHandlerFD(int fd) {
   ensureNotRegistered(__func__);
   // event_set() resets event_base.ev_base, so manually restore it afterwards
   struct event_base* evb = event_.ev_base;
-  event_set(&event_, fd, 0, &EventHandler::libeventCallback, this);
+  folly_event_set(&event_, fd, 0, &EventHandler::libeventCallback, this);
   event_.ev_base = evb; // don't use event_base_set(), since evb may be nullptr
 }
 
 void EventHandler::initHandler(EventBase* eventBase, int fd) {
   ensureNotRegistered(__func__);
-  event_set(&event_, fd, 0, &EventHandler::libeventCallback, this);
+  folly_event_set(&event_, fd, 0, &EventHandler::libeventCallback, this);
   setEventBase(eventBase);
 }
 
@@ -144,7 +144,7 @@ void EventHandler::ensureNotRegistered(const char* fn) {
   }
 }
 
-void EventHandler::libeventCallback(int fd, short events, void* arg) {
+void EventHandler::libeventCallback(libevent_fd_t fd, short events, void* arg) {
   EventHandler* handler = reinterpret_cast<EventHandler*>(arg);
   assert(fd == handler->event_.ev_fd);
   (void)fd; // prevent unused variable warnings
@@ -155,9 +155,9 @@ void EventHandler::libeventCallback(int fd, short events, void* arg) {
   }
 
   // this can't possibly fire if handler->eventBase_ is nullptr
-  (void) handler->eventBase_->bumpHandlingTime();
+  handler->eventBase_->bumpHandlingTime();
 
-  handler->handlerReady(events);
+  handler->handlerReady(uint16_t(events));
 
   if (observer) {
     observer->stopped(reinterpret_cast<uintptr_t>(handler));