LCOV - code coverage report
Current view: top level - lib/tevent - tevent_wakeup.c (source / functions) Hit Total Coverage
Test: coverage report for master 2f515e9b Lines: 14 17 82.4 %
Date: 2024-04-21 15:09:00 Functions: 2 2 100.0 %

          Line data    Source code
       1             : /*
       2             :    Unix SMB/CIFS implementation.
       3             :    Infrastructure for async requests
       4             :    Copyright (C) Volker Lendecke 2008
       5             :    Copyright (C) Stefan Metzmacher 2009
       6             : 
       7             :      ** NOTE! The following LGPL license applies to the tevent
       8             :      ** library. This does NOT imply that all of Samba is released
       9             :      ** under the LGPL
      10             : 
      11             :    This library is free software; you can redistribute it and/or
      12             :    modify it under the terms of the GNU Lesser General Public
      13             :    License as published by the Free Software Foundation; either
      14             :    version 3 of the License, or (at your option) any later version.
      15             : 
      16             :    This library is distributed in the hope that it will be useful,
      17             :    but WITHOUT ANY WARRANTY; without even the implied warranty of
      18             :    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
      19             :    Lesser General Public License for more details.
      20             : 
      21             :    You should have received a copy of the GNU Lesser General Public
      22             :    License along with this library; if not, see <http://www.gnu.org/licenses/>.
      23             : */
      24             : 
      25             : #include "replace.h"
      26             : #include "tevent.h"
      27             : #include "tevent_internal.h"
      28             : #include "tevent_util.h"
      29             : 
      30             : struct tevent_wakeup_state {
      31             :         struct timeval wakeup_time;
      32             : };
      33             : 
      34       94446 : struct tevent_req *tevent_wakeup_send(TALLOC_CTX *mem_ctx,
      35             :                                       struct tevent_context *ev,
      36             :                                       struct timeval wakeup_time)
      37             : {
      38         969 :         struct tevent_req *req;
      39         969 :         struct tevent_wakeup_state *state;
      40             : 
      41       94446 :         req = tevent_req_create(mem_ctx, &state,
      42             :                                 struct tevent_wakeup_state);
      43       94446 :         if (!req) {
      44           0 :                 return NULL;
      45             :         }
      46       94446 :         state->wakeup_time = wakeup_time;
      47             : 
      48       94446 :         if (!tevent_req_set_endtime(req, ev, wakeup_time)) {
      49           0 :                 return tevent_req_post(req, ev);
      50             :         }
      51       93477 :         return req;
      52             : }
      53             : 
      54       26791 : bool tevent_wakeup_recv(struct tevent_req *req)
      55             : {
      56          23 :         enum tevent_req_state state;
      57          23 :         uint64_t error;
      58             : 
      59       26791 :         if (tevent_req_is_error(req, &state, &error)) {
      60       26791 :                 if (state == TEVENT_REQ_TIMED_OUT) {
      61       26791 :                         return true;
      62             :                 }
      63             :         }
      64             : 
      65           0 :         return false;
      66             : }
      67             : 

Generated by: LCOV version 1.14